Creating user-friendly and SEO-optimized URL structures is crucial for improving your website's search engine rankings and user experience. Drupal 9, a powerful content management system, offers several options to create custom URL patterns that enhance the site's overall structure. In this blog post, we'll show you how to create URL aliases based on parent menu links in Drupal 9 using the Pathauto module. This approach ensures that your website has a coherent and easy-to-navigate URL structure, which is essential for SEO.


Before we begin, make sure you have the following:

  1. A Drupal 9 website with administrative access.
  2. The Pathauto module installed and enabled. You can download it from

Step-by-step guide

Follow these steps to create URL aliases based on the parent menu link and the node title.

Install and enable the Pathauto module

If you haven't already, download the Pathauto module from the Drupal project page and install it on your Drupal site.

composer require drupal/pathauto

You can enable the module using the Drupal UI or by running the following Drush command:

Configure the Pathauto module

Navigate to Configuration > Search and metadata > URL aliases in the Drupal admin menu (/admin/config/search/path). Click on the "Patterns" tab.

Create a new path pattern for your content type

Click on "Add Pathauto pattern." Choose the content type for which you want to create the URL alias pattern. Set the pattern to use the parent menu link and the node title, like this:


This pattern will create aliases based on the parent menu link's URL and append the node title at the end. The join-path function will concatenate the parent menu items' paths. Save the new pattern.

Bulk generate aliases

If you want to generate aliases for existing content, go back to the main URL aliases page (Configuration > Search and metadata > URL aliases) and click on the "Bulk generate" tab. Select the content types you want to generate aliases for and click on "Update."


Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!