Automatically Generate URL Aliases in Drupal with Pathauto

Опубликовано: 10 Июнь 2024
на канале: WebWash
318
8

Managing URL aliases in Drupal can be time-consuming. Manually updating them for every page is inefficient, especially for sites with lots of content.

Luckily, there's a module called Pathauto that can automate this process.

Pathauto uses a pattern system to automatically generate URL aliases based on content properties, like the page title. This saves you from having to edit each page individually.

Here's how to set up Pathauto:

1️⃣ Install Required Modules:

↳ Download the "Token" module and the "Pathauto" module.

↳ Install both in the "Extend" section in your Drupal admin panel.

2️⃣ Configure URL Aliases:

↳ Go to "Configuration" and then "URL aliases."

↳ You will see a few new tabs. Click on "Patterns."

3️⃣ Create a Pattern:

↳ Click "Add Pathauto pattern."

↳ Select "Content" for the "Pattern type."

↳ In the "Path pattern" field, type "/articles/[node:title]". This creates a URL structure that starts with "articles" and ends with the page title.

↳ Choose "Article" under "Content type" to apply this pattern to all articles on your site.

↳ Give the pattern a label, like "Article content type," and save it.

4️⃣ Enable Automatic Alias Generation:

↳ Edit an existing article or create a new one.

↳ Scroll down to the "URL alias" section. You should now see a checkbox labelled "Generate automatic URL alias."

This option should be checked by default. If you want to change the URL, just uncheck it and customize.

↳ Save the article. Pathauto will create a URL alias based on the pattern you defined.


5️⃣ Bulk Generate Aliases:

↳ If you want to apply this new pattern to existing content, return to "Configuration" and then "URL aliases."

↳ Click on the "Bulk generate" tab.

↳ Select "Content" and then choose one of the options:

-↳ Generate a URL alias for un-aliased paths only: This will create aliases for content that doesn't have them yet.

-↳ Update the URL alias for paths having an old URL alias: This updates existing aliases that were created with a different pattern.

-↳ Regenerate URL aliases for all paths: This recreates all aliases on your site.


Important Notes:

↳ Before using bulk generate, always back up your database. This will help you restore your site if something goes wrong.

↳ Test these changes on a development or staging site before applying them to your live website.

Using Pathauto can significantly simplify the process of managing URL aliases in Drupal. It ensures consistent URL structures and saves you time and effort.

Subscribe to our newsletter for updates: https://www.webwash.net/newsletter

Connect with us:
https://www.webwash.net/
   / webwashnet  
  / webwashnet  
  / webwashnet  
  / webwashnet  
  / webwash  
  / webwash  


Смотрите видео Automatically Generate URL Aliases in Drupal with Pathauto онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь WebWash 10 Июнь 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 31 раз и оно понравилось людям.