Add tag to slug and redirect to new pages

Add tag to slug and redirect to new pages

Digital Marketing

If you're looking to add a category tag slug to your permanent links in ghost you can easily update the config files to allow this. Follow these initial steps to download the files:

  • Log in to your Ghost admin panel.
  • In settings navigate to the Labs section. 
  • Within Labs, you'll find options to download two files: routes.yaml and redirects.yaml.


If you want to have the primary tag as the tag in the permalink the first step is to update the routes.yaml file.

You can add the primary_tag dynamic variable to the permalink setting as when below. 

permalink: /{primary_tag}/{slug}/


After you have done this your URLs will have changed so to ensure Google updates correctly and provides a good user experience you need to setup 301 redirects as shown below. For each page you will need to add one line and replace the 'original-url' with your original page url and also update with the 'newtag/new-url' with your new url.

Redirect rule:

^/original-url/$: /newtag/new-url/

Once you have updated these files you can upload them via eat e'labs' section and your ghost blog will now have a new tag structure and 301 redirects to the new URLs.

Please check the sources below for additional information on the steps we took to get our blog to show tags and add successful redirects.


How to create URLs that include post tag
Hi, I’m new-ish to Ghost, and despite Googling my problem and reading up on routing, I can’t figure out what should be a pretty simple and common task, so I must be missing something. Help is appreciated. Right now, my posts are publishing like:{slug} I would like to change this so the permalink includes the name of a tag—for the sake of this example, let’s say the tag I want is report. I edited the routes.yaml file to include this, but unfortunately my change does not work. The UR…
How do you write this redirect?
I’d like to redirect from /review/ to /tag/review/ but if I type the following line into the redirect file I get a recursive loop. Is there a workaround? /review: /tag/review/


Sign up or Sign in to join the conversation.