Questions tagged as ['path-aliases']

Use it for questions about path aliases, a way of creating pretty human readable URLs to replace system URLs like node/[nid].
Score: 2
How to check if path alias exists
in flag

In Drupal 8, my custom module includes the code

if (\Drupal::service('path.alias_storage')->aliasExists($path, 'en')) {
    return true;

What should this look like in Drupal 9.2? Seems so simple, but I can't figure it out after reading every post I can find.

Score: 2
RitikaDesai avatar
How to automatically generate two aliases for the same node?
kr flag

I am working on a Drupal website. I need to automatically generate 2 url aliases for the same node on the website. I have tried installing Pathauto but it lets me generate only 1 alias when a new page is created. Is it possible to have it automatically create 2 aliases when the page is created?

Do we do this via the module itself or can we have this done by code?


Score: 0
How can I filter the path aliases by node id?
kr flag

On this page admin/config/search/path, we can only filter the results by URL alias.

I want to filter the results by node id as well?

How can I do that?

It is not possible with form alter. As the original form submit is redirecting to the entity.path_alias.collection route with the url alias filter only.

Is there any way, I can filter them by node id?

Score: 2
Jaypan avatar
How do I create multilingual user path aliases?
de flag

I'm setting up a multilingual site, and I need the user path aliases to be multilingual.

Users are set up as translatable: User Translation Configuration

Language Detection: URL (path prefix)

  • English: /en
  • Japanese: No prefix

Pathauto patterns:

  • English: /en/users/[user:name]
  • Japanese: '/users/[user:name]

Pathauto Patterns


  • Username: Admin

Expected paths:

  • English: /en/users/admin
  • Japanese: /users/admin


  • English: /en/user/1
Score: 1
Shakil Ahmad avatar
Generate same Path aliases for multi languages
ar flag

I have a content type Products. A pattern is defined via the Pathauto module for product CT. but my issue is that when I translate an entry/node it generates a translated path alias for Urdu in Roman-English(Urdu in English alphabet) But the spellings of that path are meaningless. When I uncheck "Transliterate prior to creating alias" It generates the aliases in pure Urdu which is unacceptable in my  ...

Score: 0
Getting different Public path for admin and anonymous users
cn flag

My site was built using Lightning Drupal distribution.

I had my public path as /sites/default/files. I did change the configuration path to /sites/<my_domain>/files in the middle of the project. From then, when I upload an image to a node it's taking the destination as /sites/<my_domain>/files as expected.


I've created a view block to display the node titles and images on the home pa ...

Score: 1
JemoeE avatar
How do I programmatically create a path alias?
vn flag

How do I programmatically create a path alias in Drupal 9?

I'm creating node, but I also want to give the node a URL alias, but cannot figure out what class to use, PathAlias or AliasManager or ...?

Score: 0
shelane avatar
How do you batch process a path alias change for nodes that includes a menu placement change?
cn flag

We have an annual reporting sites that contains approximately 200 nodes each year. When the next year's reports are complete, all of the current year's nodes move to a path like /archives/fy2020/*. Not only do their paths change, but the menu items change as well to 1) create a new entry year 2) move menu items to the new entry year as the parent.

I am looking at what type of batch process I can used to ...

Score: 2
Yuseferi avatar
Change priority of different aliases with the same aliases
cg flag

There is vocabulary, let's call it forum tags which contain all forum tags, Also, in Forum, the link for the Forum container using a similar tag pattern for the forums. for example,

Term name : windows
term alias: /forum/windows

Forum container: windows
forum alias:     /forum/windows

if I open /forum/windows always term page will be loaded which means it has a higher priority.

at the moment all requ ...

Score: 0
Greg Sims avatar
Update Alias Programmatically
us flag

I have a large website with 240 urls that need to be updated. I would like to do this programmatically to avoid making errors. I created the following function which seems to work. There seems to be a good bit of complexity here for what I am trying to accomplish. Is there a simplier way to update the url of a node?

function alias_replace($path, $lang, $new_alias) {

  $path_alias_manager = \Dr ...
Score: 0
Using Drush 10 and sql-sync with path based sites not working
in flag

We have two websites running off a single domain:

Both websites have their own databases and are hosted by Acquia.

We've been using Drush 8.x and the sql-sync command for the past number of years to synchronizing the database between the local environment and Acquia.

Last week we upgraded to using Drush 10.3.6 and now we're running i ...

Score: 1
berliner avatar
How to create automatic url alias for taxonomy/term/%tid/feed
bd flag

How can I set automatic URL aliases for taxonomy feeds?

Say I have a term with tid=1, named holidays, with a system URL of /taxonomy/term/1 that is accessible by the URL alias /holidays. Then I want the rss feed for that term to be accessible on the URL alias /holidays/feed or /holidays/rss.xml. That sounded rather easy when I first thought about it, but it seems that pathauto is not supporting that (o ...

Score: 0
bigboy avatar
Node url alias pattern based on taxonomy not working properly
gu flag

I have taxonomy named Category with two terms: News and Articles.

Articles term has custom url alias - /useful.

The website was upgaded from D7 to D9. On old D7 version node url pattern was [node:field_categories]/[node:title]

On D9 it is the same pattern, BUT instead of /useful/node-title it dispalays /articles/node-title

Maybe it is not a big deal, but after porting to D9 I would like to maintain curr ...

Score: 2
hotwebmatter avatar
Pathauto alias full path for hierarchical taxonomy terms
nr flag

My client has content tagged by a hierarchical taxonomy of arbitrary depth.

Currently the maximum depth is three, but that could change:

└── ChildTerm
    └── GrandchildTerm

Each Term has a unique TID (of course), but many Terms (especially descendants) share identical strings for Name.

However, the full Taxonomy tree path to each term is guaranteed to be unique (two adjacen ...

Score: 1
mogio avatar
Example hook_pathauto_pattern_alter
cn flag

I do not understand the hook. I would expect, that "pattern_alter" would allow me to "alter" the "pattern". But this seems to be not the case.

I tried also to alter the alias... which also does not seem to have an effect.

Could somebody show me a working example please?

function xxx_pathauto_pattern_alter(\Drupal\pathauto\PathautoPatternInterface &$pattern, array $context) {

  /* /////////////////// ...
Score: 0
Get path (alias) from SQL query
in flag

I have a SQL query to get all nodes with their ID, title, publish date, change date, etc.

Additionally I need to get path to each of them (probably from path_alias.alias).

Now I have following (without alias):

SELECT MIN(node_field_data.nid) AS nid,node_field_data.type, node_field_data.status, node_field_data.title, node_field_data.langcode AS node_field_data_langcode, node_field_data.created, node_field ...
Score: 0
Content Translation installation breaks the website (statistics module error + aliases not taken into account)
in flag

First, I would like to say I am a total noob in Drupal and PHP but possess some knowledge on other web frameworks/languages).

Here is my path to the errors:

I used the UI to install Content Translation and Configuration Translation modules from the multilingual core (other 2 modules were already installed).

This did not work properly as it totally broke the website:

  • aliases not respected (from "/co ...