I need to add Permalink for my section/div where the ID will keep on changing whenever i update the page(custom content type).

I have achieved it through client side(Jquery) by find & get ID seems like tedious?

I have checked for module support like permalink & permalink block, Deeplink nothing seems to be helpful?

Is there is any better way to achieve it?

  • Jus to be clear, it's the fragment/anchor that will be changing, not the path, correct? E.g www.mysite.com/page-1#this-bit-changes – mediaashley Jun 28 '18 at 11:41
  • Yes exactly @mediaashley – Prasanth R Jun 28 '18 at 11:50
  • Can you explain what you are doing (the logic) with jQuery? Because the solution I have assumes that the IDs are changing, so you don't know what they were previously. – mediaashley Jun 28 '18 at 12:00

You can create permalinks, better known in the Drupal world as "aliases", using the Pathauto module.

The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change.

See Video Tutorial.


A custom theme preprocess function should help to process the page content and apply what you need (perhaps a numerical ID to each heading?).

Each node normally has a default permalink (regardless of url alias) of /node/[nid] which will automatically redirect to the actual path alias. You can see an example of this in most themes with the <link rel="shortlink" href="/node/[nid]" /> head element.

You could then permalink to individual pieces of content with /node/[nid]#[heading id]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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