Clean URLs in Drupal 8

Drupal is a very powerful and robust content management system. However, the Drupal standard installation does not include the feature to make URLs out of article titles. Instead, the default URL in Drupal is like this: yoursite.com/node/1. This tutorial will walk you through the process of making article titles the URLs in Drupal 8.

1. Install and activate the required modules.

(Refer to the tutorial How to Install a Module in Drupal 8.)

2. Log in to the dashboard of your Drupal site and click on the Configuration tab at the top menu.

3. The Configuration page appear. Scroll down the page to the Search and Metadata section.

Drupal 8 Search and Metadata

4. Click on URL aliases.

5. The URL aliases page will appear. Click on the Patterns tab.

Drupal 8 URL Aliases

6. The Patterns page will appear. Click on the Add Pathauto pattern button.

7. The Add Pathauto pattern page will appear. Choose Content from the dropdown list below Pattern type.

Drupal 8 Add Pathauto pattern

8. More options will appear. Click in the field below Path pattern and then click on the Browse available tokens link.

Drupal 8 Add Pathauto pattern

9. The Available tokens window will pop up at the bottom-right corner of the screen.

Drupal 8 Available tokens

10. Click on the arrow beside Nodes in the Available tokens window.

11. Scroll down the Available tokens window and look for Title. Click on [node:title] which is right next to Title.

Drupal 8 Available tokens

12. Click on the x at the top-right corner of the Available tokens window to close it.

13. In Content type on the Add Pathauto pattern page, tick the checkboxes for Article and Basic page.

Drupal 8 Add Pathauto pattern

14. Type the word Content in the field below Label.

15. Make sure the checkbox for Enabled is ticked.

16. Click on the Save button.

17. You will be brought back to the Patterns page and a message with a green background will be displayed across the page (towards the top) confirming that the Pattern Content was saved.

18. Click on the Settings tab.

19. The Settings page will appear. Scroll down the page to the Strings to Remove section and delete all the words from the field below it. This will tell Drupal to include all words from article titles in generating article URLs.

Drupal 8 Pathauto settings

20. Click on the Save configuration button.

21. Click on the Bulk generate tab.

22. The Bulk generate page will appear. Here you can generate URL aliases for existing contents, taxonomy terms and users. After ticking the checkboxes that apply to your site, click on the Update button.

Drupal 8 Pathauto pattern bulk generate