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.
In this tutorial, I'll show you the current way to use Pathauto with your 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. Also, if you're using Drupal 7, try our complete video class on using Pathauto.
Video on using Pathauto in Drupal 8
This video is taken from our Drupal 8 classes, available to OSTraining members.
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.
Step #2. Create the Pathauto patterns
- Go to Configuration > URL aliases > Patterns.
- Click "Add Pathauto pattern".
In this example, we'll create a pattern for our Drupal content.
- Pattern type: choose "Content".
- Path pattern: click the "Browse available tokens" link.
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]
- 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".
- Click the "List" tab and you should see your new URL aliases: