Calendar Icon - Dark X Webflow Template
January 10, 2025
Clock Icon - Dark X Webflow Template
 min read

Add a tag to slug and redirect to new pages in your ghost blog

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.

Add a tag to slug and redirect to new pages in your ghost blog

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.

Routes.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}/

Redirects.yaml

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 set up 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.

sources:

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…

forum.ghost.org

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…

forum.ghost.org

Latest articles

Browse all