How to have blog urls have topic name in subdirectory?

Hi
I want to have a ghost blog where blog urls have topic name in subdirectory. For example

https://domain.com/topic1/blog-title1
https://domain.com/topic2/blog-title2

Currently a ghost blog is installed in a subdomain or a subdirectory - and the blog title comes after that -
e.g.

domain.com/subdirectory/blog-title

Instead of having a single subdirectory - can I have multiple subdirectories based on topic? Please advise

Tags don’t serve the purpose as it creates only onepage for tags

Hey @pranay01,

Tags would be the right way to go about it, but you need to change how your routing works. Head over to your Settings within Ghost admin and download your routes.yaml file. Edit the collections block like so:

collections:
  /:
    permalink: /{primary_tag}/{slug}/
    template: index

Save the file and upload it back into Ghost admin via the same setting. Now whenever you publish a post the URL will contain the primary tag that was set on the post.

Hope this helps!

Hey @DavidDarnes

Thanks. Though it doesn’t work as I want.

Currently my blog is at
https://domain.com/blog/blog-title
Currently I install ghost in domain dot com/blog/ when installing

With the change you have suggested it has become
https://domain.com/blog/tag/blog-title

How do I make it
https://domain.com/tag/blog-title

You’ll need to install Ghost on the main domain and not on the subdirectory

If I install Ghost on the main domain, can I have some pages served by my webserver (say express server) and pages which are present in ghost be served by ghost server? How can I do this easily?

Your webserver (e.g. nginx or apache) should have the ability to specify routes - e.g. you can override /unicorns to proxy to your express server and /dragons to ghost

1 Like

What if don’t know all pages being served by express and ghost - is there a way to do this then? Till now I had been directing all requests with /blog to Ghost - but if I install Ghost in main domain then that won’t be possible