Automatically generate URL aliases in Drupal using Pathauto and Redirect

By xngo on February 21, 2019

Overview

Search engine optimization, SEO, is always welcome to broaden your website's reach. There are 2 Drupal modules that are SEO-friendly.

  • Pathauto automatically converts your URL paths using aliases such as node title, taxonomy terms, etc. So, for example, instead of showing URL path /node/1, it will show something like /article/my-post-title. It is human readable and SEO-friendly.
  • Redirect will ensure that when your aliases change, Drupal will still load the page /node/1. It also notifies search engine that the page is permanently moved with HTTP status code 301. Without this module, users will get 404 - page not found error.

Install

Create Pathauto patterns

  1. Go to Configuration->URL aliases. Click on Patterns tab.
  2. Click on the Add Pathauto pattern button.
  3. Select Content from Pattern type and enter article/[node:title] into Path pattern. If you want to see the available patterns, click on Browse available tokens .
  4. Check Article from Content type.
  5. Enter a name for this pattern in Label.
  6. Save.

Bulk generate

If you already have a bunch of existing articles and want to generate aliases for them, then click on the Bulk generate tab. First, select which entity type you want to mass generate, e.g. Content. Then select which URL aliases to generate.

Redirect

No setting to do. By default, Redirect is set to automatically create redirects when URL aliases are changed.

Reference

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.