Pathauto

Automatically generates URL aliases for content based on configurable token patterns, eliminating the need for manual alias creation.

pathauto
488,913 sites
308
drupal.org
Drupal 8 Drupal 9 Drupal 10 Drupal 11

Install

Drupal 11, 10 v8.x-1.14
composer require 'drupal/pathauto:8.x-1.14'
Drupal 9 v8.x-1.13
composer require 'drupal/pathauto:8.x-1.13'
Drupal 8 v8.x-1.10
composer require 'drupal/pathauto:8.x-1.10'

Overview

Pathauto is a module that automatically generates URL aliases for various types of content (nodes, taxonomy terms, users) without requiring manual path specification. This enables search-engine-friendly URLs like /category/my-article-title instead of /node/123.

The module uses a pattern system based on tokens that administrators can configure. Patterns can be created per entity type, per bundle, and even per language for multilingual sites. The module handles alias uniquification automatically by appending numeric suffixes when conflicts occur.

Pathauto integrates seamlessly with Drupal's path system and can be configured to either leave existing aliases intact, create new aliases alongside old ones, or replace old aliases when content is updated. It also provides bulk generation and deletion capabilities for managing aliases across large amounts of content.

Features

  • Automatic URL alias generation based on configurable token patterns for nodes, taxonomy terms, users, and other content entities
  • Pattern-based alias creation supporting entity type, bundle, and language-specific patterns with weighted priority
  • Token replacement system allowing dynamic alias components like [node:title], [term:vocabulary], [user:name]
  • Automatic alias uniquification that appends numeric suffixes (-0, -1, etc.) when alias conflicts occur
  • Configurable update behavior: do nothing, create new alias keeping old, or replace old alias
  • Bulk generation of URL aliases for existing content that lacks aliases
  • Bulk deletion of aliases with options to preserve manually created aliases
  • Transliteration support to convert accented characters to ASCII equivalents
  • Configurable punctuation handling (remove, replace with separator, or keep)
  • Ignore words feature to strip common words from aliases (a, an, the, etc.)
  • Maximum alias and component length configuration to prevent overly long URLs
  • Safe tokens configuration to prevent cleaning of certain token types like URLs and paths
  • Integration with Redirect module for creating redirects when aliases change
  • Drush commands for alias generation and deletion via command line
  • Per-entity pathauto checkbox allowing manual override of automatic alias generation

Use Cases

SEO-Friendly Content URLs

Create human-readable URLs for content based on titles. Set up a pattern like [node:title] for articles to get URLs like /my-article-title instead of /node/123. This improves SEO by including keywords in URLs and makes links more shareable and memorable.

Hierarchical Taxonomy URLs

Generate URLs that reflect taxonomy hierarchy using patterns like [term:vocabulary]/[term:parents:join-path]/[term:name]. This creates URLs like /categories/electronics/smartphones for deeply nested terms.

Content Type Specific Patterns

Configure different URL patterns per content type. Blog posts might use blog/[node:created:custom:Y/m]/[node:title] for date-based URLs, while product pages use products/[node:field_category]/[node:title] for category-based URLs.

Multilingual Site URL Management

Create language-specific patterns that generate appropriate aliases for each language version of content. Configure patterns per language to use localized prefixes or translated tokens.

User Profile URLs

Enable Pathauto for users to generate clean profile URLs. Use patterns like users/[user:name] or team/[user:field_department]/[user:name] for organized, memorable profile pages.

Bulk URL Migration

When migrating from another CMS or restructuring URLs, use the bulk generation feature to regenerate all aliases at once. Combined with the Redirect module, old URLs are preserved as redirects.

Clean Up Legacy Aliases

Use the bulk delete feature to remove old auto-generated aliases while preserving manually created ones, then regenerate with new patterns for a fresh URL structure.

Tips

  • Always install the Redirect module alongside Pathauto to automatically create redirects when aliases change, preserving SEO value and preventing 404 errors.
  • Use the Token browser (link appears when editing patterns) to discover available tokens for your entity types and their fields.
  • Set pattern weights strategically: more specific patterns (bundle + language) should have lower weights (higher priority) than general patterns.
  • Test patterns on existing content before enabling for new content by using the bulk update feature with 'Generate for un-aliased paths only'.
  • Add common words to 'Strings to Remove' to keep aliases concise (articles like 'a', 'the' are included by default).
  • For date-based URLs, use token formats like [node:created:custom:Y/m/d] to get paths like /2024/03/15/article-title.
  • The 'Safe tokens' setting prevents cleaning of URL-like tokens. Add custom token names if you have tokens that output pre-formatted path components.
  • Use the Drush commands (pag, pad) for large-scale alias operations on production sites, as they're more efficient than the UI for batch processing.
  • Review and test punctuation settings carefully - different sites may need different handling of characters like periods or underscores.

Technical Details

Admin Pages 5
Patterns /admin/config/search/path/patterns

Manage URL alias patterns. This page lists all configured Pathauto patterns with their type, pattern string, and enabled status. Patterns can be reordered by weight to control priority (patterns with lower weights are evaluated first).

Add Pathauto pattern /admin/config/search/path/patterns/add

Create a new URL alias pattern. Define the entity type, token pattern, optional bundle and language conditions, and administrative label.

Settings /admin/config/search/path/settings

Configure global Pathauto settings including separator character, maximum alias length, case handling, transliteration, ignore words, update behavior, and punctuation handling.

Bulk generate /admin/config/search/path/update_bulk

Generate URL aliases in bulk for existing content. Select entity types and choose whether to generate for un-aliased paths only, update existing aliases, or regenerate all aliases.

Delete aliases /admin/config/search/path/delete_bulk

Bulk delete URL aliases. Choose to delete all aliases or aliases for specific entity types. Option to preserve manually created aliases.

Permissions 4
Administer pathauto

Allows a user to configure pathauto settings, configure patterns for automated aliases, bulk update and delete URL-aliases.

Notify of Path Changes

Determines whether or not users are notified when path aliases are created or changed.

Bulk update aliases

Allows a user to bulk update (generate) URL aliases.

Bulk delete aliases

Allows a user to bulk delete URL aliases.

Hooks 5
hook_pathauto_pattern_alter

Alter the pattern to be used before an alias is generated. Allows modification of the pattern based on context such as entity type, bundle, operation, and language.

hook_pathauto_alias_alter

Alter the generated alias before it is saved. Allows modification of the final alias string and context values like language.

hook_pathauto_is_alias_reserved

Determine if a potential URL alias conflicts with any existing reserved paths. Return TRUE to prevent the alias from being used.

hook_pathauto_punctuation_chars_alter

Alter the list of punctuation characters that Pathauto can handle during alias generation.

hook_path_alias_types_alter

Alter the alias type plugin definitions. Allows modification of how different entity types are handled for alias generation.

Drush Commands 2
drush pathauto:aliases-generate

Generate or regenerate URL aliases in bulk

drush pathauto:aliases-delete

Delete URL aliases in bulk

Troubleshooting 7
URLs are not being replaced with aliases on the site

Only URLs passed through Drupal's URL and Link APIs are replaced. Hardcoded links in templates like href="/node/123" will not be replaced. Use Drupal's url() function or link templates instead.

Pathauto is not generating aliases for a content type

Ensure a pattern exists for that content type at /admin/config/search/path/patterns. If the default pattern is blank and no bundle-specific pattern exists, aliases won't be generated. Check that the pattern is enabled.

Alias conflicts are creating unwanted suffixes (-0, -1, etc.)

This happens when multiple items would have the same alias. Make patterns more unique by including additional tokens like [node:nid] or [node:created:custom:Y-m-d] to differentiate similar titles.

Special characters are appearing in aliases

Check the Punctuation settings at /admin/config/search/path/settings. Ensure the problematic character is set to 'Remove' or 'Replace by separator'. Enable transliteration if accented characters are the issue.

Existing aliases are not being updated when content changes

Check the 'Update action' setting. If set to 'Do nothing', existing aliases are preserved. Change to 'Create a new alias. Delete the old alias.' for automatic updates.

Bulk generate is not creating aliases for existing content

If content already has aliases and 'Update action' is set to 'Do nothing', bulk generate will skip those items. Select 'Regenerate URL aliases for all paths' in bulk generate, or change the Update action setting first.

Aliases are too long and getting truncated unexpectedly

Adjust 'Maximum alias length' and 'Maximum component length' settings. The default is 100 characters. Ensure individual tokens don't exceed component length, which causes truncation at word boundaries.

Security Notes 3
  • The 'Administer pathauto' permission is powerful and should only be granted to trusted administrators, as incorrect patterns could expose internal paths or create confusing URL structures.
  • Bulk delete operations are irreversible and have no confirmation dialog. Always backup the path_alias table before performing bulk deletions.
  • Be cautious with patterns that include user-generated content tokens, as malicious users could potentially influence URL structures if input isn't properly sanitized by the token provider.