“The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias” - Drupal.org
Considered as one of the best practices for SEO, it is essential that your Uniform Resource Locator aka URL assists any layman in locating your resources easily. A crucial element when preparing your website for SEO or better UX, it is often overlooked by organizations. URLs play a very crucial role in the ranking of your website.
Modern search engines give preference to URLs which are:
|
By default, Drupal assigns URL of the format node/[node:nid] to content items, taxonomy/term/[term:tid] to taxonomy terms, and user/[user:uid] to the users. URL aliases can be added either while creating the content items or by adding URL alias manually for each system Path using
Manage → Configuration → Search and metadata → URL aliases.
This built-in functionality works due to the Path module which comes with Drupal core.
Often you will come across one of the two issues when following URL practices:
|
Pre-Requisites
It requires the following modules to be pre-installed and enabled:
Downloading and Installing Pathauto
It can be downloaded and installed just like any other module in Drupal. Any of the four methods below can be followed to install Pathauto.
- Using UI
- Navigate to Manage → Extend → Install new module and enter the .tar.gz or .zip URL of the module and hit Install
- Once the downloader and installer are finished downloading, click on “Enable newly added modules”.
- Find Pathauto in the list of modules, select it and click on Install.
For rest of the methods, first, navigate to the root directory of your Drupal site, $ cd /var/www/html/drupal-8.4.4
- Using Composer
- Add Pathauto package using composer
$ composer require "drupal/pathauto"
- Enable the module by navigating to Manage → Extend, selecting Pathauto and click Install
- Using Drush
Download and enable the module using Drush
$ drush dl pathauto
$ drush en pathauto -y
- Using Drupal Console
Download and install the module using Drupal Console
$ drupal module:download pathauto
$ drupal module:install pathauto
Adding URL Patterns
Navigate to Manage → Configuration → Search and metadata, select the 'Patterns' tab and click on Add Pathauto pattern.
- Select Pattern type to Content
- Give a suitable Path pattern, eg: article/[node:author]/[node:title]. Tokens allow the creation of dynamic URL patterns, a full list can be viewed using Browse available tokens.
- Provide a Label to this URL pattern, check Enabled and hit Save.
- Similarly, URL patterns can be created for other content types, taxonomies and users.
Creating Bulk URL Aliases
This feature of Pathauto allows creating URL aliases in bulk for already existing content, taxonomies, and users.
- Navigate to Manage → Configuration → Search and metadata and select the Bulk generate tab.
- Select the entities for which you wish to generate URL aliases.
- Select the appropriate paths for which URL aliases to generate.
Deleting Bulk URL Aliases
Similar to adding URL aliases in bulk, the module also allows deleting them. However, this is not recommended on a live site.
- Navigate to Manage → Configuration → Search and metadata and select the Delete aliases tab
- Select the entities for which you want to delete URL aliases
- Check Only delete automatically generated aliases to prevent deletion of manually created aliases and click on Delete aliases now
Tweaking Pathauto
Default settings of Pathauto are optimized for SEO friendly URLs and should suffice the needs of most of the users. Few of the settings that may be tweaked as per requirements:
Settings | Description | Default Value |
Separator Character | The character used to separate words |
- |
Maximum alias length |
The maximum length of URL alias generated |
100 |
Maximum component length |
The maximum length of individual components of alias, such as [node:title] |
100 |
Strings to remove | Words to exclude from URL alias |
a, an, as, at, before, but, by, for, from, is, in, into, like, of, off, on, onto, per, since, than, the, this, that, to, up, via, with |
Punctuations |
Special characters like a comma (,), semicolon (;), etc |
Remove |
Refer {your-drupal-site}/admin/config/search/path/settings for more settings.
To Sum Up
The module helps to automate the process of creating SEO friendly URL aliases, thereby improving the ranking index of your website. You may want to redirect your existing “system paths” to the newly created URL aliases. Redirect module can be used along with Pathauto to get the desired result.
In case of any query feel free to comment below.
Subscribe
Related Blogs
RFP: How To Create An RFP For Open Source Solutions?
A good Request for Proposals (RFP) or Call for Proposals (CFP) clearly states the goals and expectations of your project and sets the…
Drupal 7 End Of Life: Top Reasons You Should Migrate To Drupal 10
Drupal 10 was released in December 2022 and ever since, the community has been pushing its users to do Drupal 7 to 10 migration. As per…
DrupalCon Barcelona: 2024 Wrap-Up From Europe
DrupalCon, the key conference for the digital experience platform Drupal, was held this year in Barcelona, Spain, from September 24 to 27…