Learn Drupal 8

Written by developers for developers, Drupal allows easy and fast development of every website!

• Last Updated: 03/05/2020
• ( 7 minutes reading )

How to automatically generate URL Aliases in Drupal using Pathauto


As a Drupal user, you have probably noticed that all your website URLs are followed by "/node". This is due to the fact that the content of a Drupal website is being stored in nodes. A node is any piece of individual content, such as a page, article, blog entry, etc. The main purpose of the nodes is content creation flexibility. Now, this is all great, but we could not agree the URLs look nice.

Fortunately, Drupal allows you to configure URL Aliases for your content items. This will allow you to have a URL, such as "domain.com/about-us" instead of "domain.com/node/1".

This is also great, but what happens if you have hundreds of pages - it is not very convenient, isn't it?

Here comes the role of the Pathauto module which allows you to automatically generate URL Aliases and eliminated the need to manually update your content items one by one. Before we begin, you should know that Pathauto is NOT a core Drupal module and requires a manual installation. This is a relatively simple task which we already covered in our How to install Modules in Drupal tutorial. In the aforementioned guide, you will find step-by-step instructions and within a few minutes, you will have the required module successfully installed and enabled on your Drupal website.

If you are still wondering what are the benefits of having ULS Aliases, commonly referred to as SEO-friendly URLs - let us point a few. URLs are one of the basic elements of SEO, yet they are essentially important and considered as a significant ranking factor. SEO-friendly URLs are not only beneficial for better indexing and search engine ranking, but they are also easily readable for your visitors.


Accessing Pathauto Configuration Page

Please note that at this point you are expected to already have the Pathauto module successfully installed and enabled on your Drupal website.

For a start, please log in to your Drupal Admin Dashboard and navigate through the Administrative toolbar to Manage Extend.

Once you access the "Extend" page, you will see a list of all currently installed modules. We would recommend you to use the search bar in order to easily locate Pathauto.

When you find it, please hit the arrow icon to expand it and click on the "Configure" link. 


Accessing Pathauto Configuration Page


This action will redirect you to the "Patterns" page where you will be able to configure the automatic generation of the URL Aliases.


Configuring Pathauto Patterns

Now, let's configure the custom pattern which will be generated whenever a new entity is created. To do so, please click on the "+ Add Pathauto pattern" button.


Add Pathauto pattern


On the "Add Pathauto pattern" page, first, you will need to select the "Pattern type" from the dropdown menu. Since we will be configuring URL Aliases for content items, please make sure to choose the "Content" option.

Right below, you will need to define the "Path pattern" in the field. In our case, we have set it up to "/article/", however you can select another relevant term, just make sure to include the forward slashes (/) before and after. Afterward, please click on the "Browse available tokens." link beneath the field to select the token which will be used to generate the actual URL. Once clicked, a new "Available tokes" dialog will appear. Please expand the "Nodes" category by clicking on the corresponding arrow icon and locate the "Title" token. You will need to select it by clicking on the blue "[node:title]" link.


Selecting the Title token


Once it is selected, you may close the dialog and continue with the rest of the details. You will notice that an additional "[node:title]" string had been added to the "Path pattern"

You will need to select the "Content type" applicable for this pattern by ticking the corresponding checkboxes. You are able to select more than one content type if required.

Under the "Label" field, you will need to enter a title for this pattern which will be only for your reference.

The "Enabled" checkbox should be left as it is - ticked.

Finally, all left to be done is to click on the "Save" button to finalize the creation of your new pattern.


Saving the pattern


Once this is done, you will be prompted with a message stating the new pattern had been successfully saved.


Pattern successfully saved message


Now, you can go ahead and test it by creating a new content item. If you have selected the same pattern as shown in the previous lines, the URL will be configured based on your content item title. For example, content with a "New Article" tile will have "domain.com/article/new-article" URL. It will automatically replace the capital letters and add hypes wherever necessary, so there is nothing else expected from you to do.

Something important to mention is that this pattern will take effect only on content items created after its configuration. Any previously created content items will not be updated.

With that being said, you know everything that should be known in regard to automatically generating URL Aliases for your Drupal content. We hope these new skills will be beneficial to you in the future. In case you have faced any difficulties or require further assistance, please do not hesitate to contact our Support Team.



Content Marketing Specialist

Sebahat is a young and bright woman who has become an invaluable part of our team. She started as a Customer Care Representative, mastering that role and, along the way, growing into a tech-savvy individual who is well acquainted with every support layer of the company. Driven by her aim to improve our customers’ experience constantly, she is committed to enhancing the extraordinary support we deliver.