How to Redirect URLs in Ghost


Post cover image

If you are looking to redirect a single post to another, or an entire section of your blog to a new URL, you can now do that inside the Ghost admin rather than needing to manually edit your Nginx file.

  1. Log into the Ghost admin section of your blog and click on 'Labs'.

  2. Scroll down to the bottom and click on 'Download current Redirects'.

  3. Open the file in Notepad or TextEdit or whatever else you use.

  4. By default it will only have [] in the file. Inside here you can add as many redirects as you wish using standard JSON formatting.

  5. Each redirect will have a from, to, and wether it is permanent or not.

    For a single post to post redirect:

     [{
         "from": "/some-old-post/",
         "to": "/some-new-post/",
         "permanent": true
     }]
    

    Or for multiple posts:

     [{
         "from": "/some-old-post/",
         "to": "/some-new-post/",
         "permanent": true
     },
     {
         "from": "/some-old-post2/",
         "to": "/some-new-post2/",
         "permanent": true
     },
     {
         "from": "/some-old-post3/",
         "to": "/some-new-post3/",
         "permanent": true
     }]
    
  6. The to and from can also take regex examples. Here is an example from Ghost's official documentation on how to redirect your posts from [domain].com/post/year/post-name/ to [domain].com/postname/:

     [{
         "from": "^/post/[0-9]+/([a-z0-9\\-]+)",
         "to": "/$1/"
     }]
    
  7. Once you have created your file, go back over to your Ghost admin, and click on the 'Upload redirects JSON' button and upload your JSON file. Unless there are any errors, it will take effect immedietly.

There is some basics to get you started and accomlish the simple tasks. But, Ghost put together TONS of examples on their documentation about all different kinds of redirects. Check it out here.