This question might have asked here before so my apologies but I couldn’t get a satisfactory answer.
I have run a blog on word press for a few years and currently moving to ghost, we used to have a category, subcategory and tags there which made things quite easy to organise the blog posts.
For example -
Post: “How to convert string to integer in Python”
This I would like to put in -
Category - Programming
Subcategory - Python
Tags - tutorial(just like this, it could be news also)
In the editor, I couldn’t find any place to mention category or subcategory, however, I did see tags which are equivalent to categories from word press. I also read some other questions here on the forum and someone replied that we can leverage dynamic routes. But I cant think how to manage category, subcategory and tags using dynamic routes.
If someone can point the correct direction to me, I would really appreciate that.
Tldr: How to implement categories, subcategories and tags.
Ghost only has tags. Just tags.
Some options discussed here:
In particular - consider putting your category as the primary tag (first tag), which lets you automatically put it into the URL. So you can get to /programming/your-post-name easily.
Getting more complex urls like /programming/python/your-post-name is not as easy.
A couple options:
-
Make your primary tag actually be “Programming > Python” with the slug “programming-python”, so your URLs are /{programming-python}/{your-post-name}. That’s automatic and super easy.
-
Create a separate route for each category, filtered by that tag (i.e. Programming). Write a routes.yaml file that puts each category into the URL. Make the subcategory the primary tag, and the category later in the list of tags. That lets you get:
/programming/{primary_tag}/{your-post-name}
But if you also have recipes, you’ll have to add an entry for that, too.
/recipes/{primary_tag}/{your-post-name}
… but at least it’s only one routes.yaml entry per category, so hopefully not too many or too frequent changes.
-
Manually route every single post. That lets you do things like include every single tag, but it’s going to be a pain in the butt. I don’t think this is worthwhile.
You can write a line in the routes file to serve up /programming/python/version-3.2/somethingelse/yourpostname, but you’ll also need one for /programming/python/version-3.2/somethingelse/yourotherpost and /programming/python/version-3.2/somethingelse/yourthirdpost … ugh! I wouldn’t do this.
1 Like
Thanks for such detailed explanation, cathy.