Many modules have been in flux during the early stages of Drupal 8’s development. Few modules have changed as much as Pathauto, which the vast majority of Drupal sites use to control their URLs.

How to Use Pathauto in Drupal 8 Site?

Before we begin, it’s worth noting that it is much easier to do this *before* launching your site. It’s never easy to change URLs after launch.

Step #1. Install the modules

You will need these three modules:

Yes, all three are marked as “Alpha”, but that’s the best we have right now.

  • Install and enable those three modules.

Now, let’s see if it’s working correctly.

  • Click Content > Add content and choose a content type.
  • Make sure that the “Generate automatic URL alias” box is checked. This should be checked for new content, but you may have to enable it manually for existing content.

How to Use Pathauto in Drupal 8 Site?

Step #2. Create the Pathauto patterns

  • Go to Configuration > URL aliases > Patterns.
  • Click “Add Pathauto pattern”.

How to Use Pathauto in Drupal 8 Site?

In this example, we’ll create a pattern for our Drupal content.

  • Pattern type: choose “Content”.
  • Path pattern: click the “Browse available tokens” link.

How to Use Pathauto in Drupal 8 Site?

You’ll see a pop-up box with tokens that you can use. For example, if you want to use elements from your content to create URLs for your content, click “Nodes”. Underneath, you will see

In this example, I’m going to use the content type and the Node ID. This will create URLs like this: /articles/1/.

So, in “Path pattern”, I enter [node:content-type] and also [node:nid]. The exact format I choose is [node:content-type]/[node:nid]

How to Use Pathauto in Drupal 8 Site?

  • Content type: Check all your content type boxes.
  • Label: Choose a name for this pattern. Only admins will see this.

Step #3. Generate the URLs

Now we need to generate the URLs for our existing content.

  • Click the “Bulk generate” tab.
  • Check the “Content” box.
  • Click “Update”.

How to Use Pathauto in Drupal 8 Site?

  • Click the “List” tab and you should see your new URL aliases:

How to Use Pathauto in Drupal 8 Site?

0 Likes
650 Views

You may also like

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter message.