“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:
Short and crisp
Legible
No request parameters
No URL unsafe characters
Important keywords
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:
Content items are added without adding proper URL alias.
Content publisher (who write and publish content) lacks proper knowledge of SEO and more importantly SEO friendly URLs.
Pre-Requisites
It requires the following modules to be pre-installed and enabled:
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 InstallInstalling PathAuto using FTP
Once the downloader and installer are finished downloading, click on “Enable newly added modules”.Wait for the installer to finish downloading and installing
Find Pathauto in the list of modules, select it and click on Install.Enabling the module
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
Navigate to Manage → Configuration → Search and metadata, select the 'Patterns' tab and click on Add Pathauto pattern.
Adding the Path 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.
Few examples of Pathauto patterns
Creating Bulk URL Aliases
This feature of Pathauto allows creating URL aliases in bulk for already existing content, taxonomies, and users.
Generating URL aliases in bulk
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.
Deleting URL aliases in bulk
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.
A BIG SHOUT OUT to the bloggers and evangelists willing to impart their knowledge with their writing.
Share your experience and opinion with us and let the world be the stage to your ideas and work. Share your piece with us at [email protected]. We also welcome ideas in the planning phase.
What Do We Expect?
The content should align with our interest in web development and open source technology. However we are open to topics from in and around the industry.
An average blog post should be of around 1000 words, but this is of course subjective.
We love crazy and colourful content. Feel free to link awesome pictures, infographics, stats, and all.
We are also open to articles with cool tips and tricks, some How-to and step by step guide as well