We have a situation where we need to prevent the same URL from being generated within the same language.

Current situation (all for en):

  1. Create nodeA with a URL alias of "page/node-title"
  2. Create nodeB with a URL alias of "page/node-title"
  3. Create nodeC with a URL alias of "page/node-title"

Results of current situation

  1. nodeA generates "page/node-title"
  2. nodeB generates "page/node-title-0"
  3. nodeC generates "page/node-title-1"

Expected results:

  1. get created as expected
  2. user is prompted to modify the url since for the en language, that alias already exists
  3. user is prompted to modify the url since for the en language, that alias already exists

That is not the expected results however. When nodeB and nodeC are generated, then the user should be prompted to let them know that the URL alias is a duplicate and thus it must be changed so it is unique. We have reviewed a lot of the documents for URL generation in Drupal but cannot find the correct configuration to prevent duplicate node alias from being generated.

  • 1
    Drupal core (+ Pathauto as far as I know) doesn't have such a configuration option. Probably wouldn't be too hard to implement with a form alter and a validation function though
    – Clive
    Sep 12, 2016 at 18:02

1 Answer 1


As Clive mentions, Pathauto does not have a configuration to disable uniquification (suffixing "-#").

If you look through the main function that builds paths, pathauto_create_alias() you can see that the only way to prevent pathauto_alias_uniquify($alias, $source, $language) from running would be to trigger one of the scenarios in which pathauto gives up on alias creation (e.g. empty pattern, updating an existing alias, etc.) which wouldn't help where you need it still generated in some cases.

Your best bet to cover this scenario is to have a custom node validation function execute pathauto_create_alias()'s logic with $op = 'return' to see what the generated alias would be before generation, and throw back errors upon duplicate uniquified paths.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.