Table of Contents
Drupal is a powerful CMS with outstanding features to manage a website. However, one common challenge faced by Drupal users is creating clean, SEO-friendly URLs. It can be time-consuming and error-prone, impacting the UX and search visibility. That’s where Drupal Pathauto comes in. With it, you can create clean, readable, and SEO-friendly URLs.
In this blog, we’ll learn how the Drupal development experts install and configure the Pathauto module and what features it offers. Let’s dive in.
What Does the Drupal Pathauto Module Do?
The Drupal Pathauto module is a powerful tool that automates the creation of user-friendly URL aliases for various types of content on your Drupal website. Instead of relying on default, machine-generated URLs like /node/123, Pathauto allows you to create more readable and SEO-friendly URLs such as /category/my-node-title. Here’s how it works:
- Pattern-Based Generation: Pathauto uses customizable patterns that include tokens representing different parts of your content (like title, author, or creation date).
- Automatic Creation: When you create or edit content, Pathauto automatically generates the URL alias based on the chosen pattern.
- Customization: You have full control over the patterns, allowing you to tailor the URL structure to your specific needs and SEO strategy.
By automating the generation of URL aliases, Pathauto module saves time, reduces errors, and ensures consistency across the site.
How to Install and Configure Drupal Pathauto?
To install and configure the Drupal Pathauto module, follow the below given steps:
Step 1: Download the Pathauto module using Drush or Composer command:
composer require drupal/pathauto
Or
drush en pathauto
Alternatively, you can download the module manually from the Pathauto module page.
Step 2: Enable both the Pathauto and Token modules (as Pathauto depends on Token):
drush en pathauto token -y
Step 3: Ensure the required modules, such as CTools (for token functionalities), are also installed.
Step 4: Navigate to Configuration > Search and Metadata > URL Aliases > Patterns (/admin/config/search/path/patterns)
Step 5: Create custom patterns for different entity types, such as content types, users, or taxonomy terms. Use tokens (accessible via the “Browse available tokens” link) to define dynamic patterns. For example:
- Content: /articles/[node:title]
- Users: /profiles/[user:name]
Step 6: Assign patterns to specific content types, taxonomy terms, or other entities. For instance:
- Blog posts: /blog/[node:title]
- Categories: /category/[term:name]
Step 7: Enable Automatic Alias Updates under the Settings tab to ensure aliases are updated whenever content is modified.
Step 8: To use the bulk generate feature and apply existing patterns go to URL Aliases > Bulk Generate. After that, select the entities for which you want aliases generated.
Step 9: Click the Update button to start the bulk generation process. This will generate URL aliases for all selected content types based on the patterns you defined.
By following these steps, you’ll have a well-configured Pathauto module that generates clean, descriptive, and SEO-friendly URLs for your Drupal site.
Looking to build a Drupal website that is high-performing and SEO-friendly?
Using Drupal Pathauto Module
The Drupal Pathauto module is versatile, allowing users to automate the generation of SEO-friendly URLs (aliases) for a wide range of content entities. Here are several use cases and steps for using Pathauto in Drupal:
Automatically Generate URL Aliases for Content Types
Pathauto is most commonly used to automatically generate URL aliases for different content types (e.g., Articles, Pages, Blog posts). For example, you can set the pattern for Article content type URLs to be based on its title, like /articles/[node:title].
- Navigate to Configuration > Search and Metadata > URL Aliases > Patterns.
- Select Add Pattern and define a new pattern for content types.
- Choose Node as the entity type and set a pattern like /articles/[node:title] or /[node:type]/[node:title].
- Save the configuration.
This will automatically generate URLs for new articles based on their titles.
Bulk Generation of URL Aliases
Pathauto allows you to generate or update URL aliases for multiple pieces of content at once. Here is how you can bulk generate URL aliases:
- Go to Configuration > Search and Metadata > URL Aliases > Bulk Generate.
- Select the content types or entities for which you wish to generate aliases.
- Click Generate to automatically create aliases for selected content.
It is particularly useful after modifying patterns or for large websites with many pieces of content.
URL Patterns for Taxonomy Terms
Pathauto can also generate aliases for taxonomy terms, such as categories and tags. For example, you might want to generate patterns like [term:vocabulary]/[term:name]. Here is how you can do that:
- Go to Configuration > Search and metadata > URL aliases > Patterns.
- Click on the “Taxonomy term paths” tab.
- Enter your desired pattern in the “URL alias pattern” field. For example, [term:vocabulary]/[term:name].
- Save the configuration.
URL Pattern for User Profiles
You can create a clean URL structure for user profile pages, such as /user/[user:name], instead of using the default /user/123 URL.
- Go to Configuration > Search and Metadata > URL Aliases > Patterns.
- Select User as the entity type.
- Define the pattern /user/[user:name].
- Save the configuration.
This allows user profiles to be accessible via more friendly URLs, such as /user/johndoe.
URL Pattern for Multilingual Support
Pathauto is fully compatible with multilingual websites. You can define different patterns for each language, ensuring that URLs are localized for users in various regions.
- Go to Configuration > Search and Metadata > URL Aliases > Patterns.
- Create language-specific patterns by selecting the Language in the condition section.
- Define localized URL patterns like /en/articles/[node:title] for English and /fr/articles/[node:title] for French.
- Once done, save the configurations made.
By following the above steps, you can effectively use the Drupal Pathauto module to enhance the URL structure of your site. It will help you improve both SEO and user experience. If you are looking to build a website that performs well and is well-designed with the best practices followed, get in touch with our Drupal development company.
Key Features of Drupal Pathauto Module
The Drupal Pathauto module offers several key features that streamline the creation and management of URL aliases on your site. Here are the most important ones:
Automatic URL Alias Generation
Pathauto automatically generates URL aliases for various types of content, including nodes, taxonomy terms, and user profiles. This eliminates the need for manual URL entry, saving time and reducing errors.
Benefit: Ensures consistency and reduces the risk of human error in URL creation.
Token Support
Pathauto uses the Token module to create dynamic URL patterns. Tokens are placeholders that represent different pieces of content, such as the title, date, author, or taxonomy terms.
Benefit: Allows for highly customizable and dynamic URL structures tailored to specific needs.
Bulk Generation of URL Aliases
Pathauto can generate URL aliases in bulk for existing content. This is particularly useful for sites with a lot of existing content or for migrating sites.
Benefit: Saves time by automatically generating URLs for large amounts of content, ensuring consistency across the site.
Custom Pattern Configuration
Administrators can define custom patterns for different content types, taxonomy terms, and user profiles using tokens.
Benefit: Provides flexibility to create URLs that are specific to the content type and meet the site’s unique requirements.
SEO-Friendly URLs
Pathauto helps create clean, descriptive, and search engine-friendly URLs, which can improve SEO and user experience.
Benefit: Enhances search engine rankings and makes URLs more user-friendly and memorable.
Integration with Other Modules
Pathauto integrates well with other Drupal SEO modules, such as the Redirect module, to manage URL changes and avoid broken links.
Benefit: Ensures a seamless user experience by handling URL changes and avoiding 404 errors.
Performance Optimization
For large sites, Pathauto offers options to run bulk generation processes during off-peak hours or in smaller batches to minimize performance impact.
Benefit: Helps maintain site performance even when generating URLs for a large volume of content.
Multilingual Support
Pathauto supports multilingual sites, allowing for the generation of URL aliases in different languages.
Benefit: Ensures that URLs are localized and relevant to users in different regions and languages.
These features of the Pathauto module makes it an ideal choice for making your Drupal website optimized for SEO.
Need expert assistance with your Drupal project?
Wrapping Up
The Drupal Pathauto module offers a simplified way for managing URL aliases effortlessly. By automating the creation of clean, user-friendly, and SEO-optimized URLs, it ensures consistency across your site while improving search engine visibility.
Using Pathauto you can generate patterns for content types, taxonomy terms and user profiles. Plus, Pathout supports alias generation for multilingual websites that eliminates the need to create URLs manually.
If you are looking to build a robust website that is also optimized for search engines, hire Drupal developers.