Skip to main content
DrupalABC

Main navigation

  • Home
  • Search
  • Learn Drupal
  • Certifications
  • Drupal Code Finder
User account menu
  • Log in

Breadcrumb

  1. Home

Pathauto

How to make node URL alias mandatory in Drupal 8 and Drupal 9?

You can use the following code snippet to change the required attribute of the path field in the node form alter in this way:

This will keep the path tab open by default and mark the alias field as required.

How to set URL alias of node when using Pathauto module?

You can use the following code to set URL alias for a node if your website also uses Pathauto

Where $node_url is the desired alias and $node is loaded node object.

DrupalABC

Footer

  • Buy me a coffee
  • Drupal.org profile
  • LinkedIn
Powered by Drupal

Drupal is a registered trademark of Dries Buytaert