What is the difference between routes and collections?

Hi,

Could you please let me know the difference between routes and collection?
I think they seem to do the same thing: Define the URL, what will appear at that URL and under which template. So what is the difference between them and how to choose one?

Thank you in advance.

Have you checked out the docs here?

The TL;DR is that

  • routes define URLs for specific templates (among other things)
  • collections define how your content is organized and accessed via URLs
1 Like

Thank Ryan, I checked the docs but it is not quite clear to me.
Is it wrong if I have a configuration like this:

routes:
  /blog/: blog
    
collections:
  /blog/:
    permalink: /blog/{slug}/
    template: blog

You only need the collections key as that sets up the URL and the collection

1 Like

Hey Ryan,

  1. Is there any risk for creating collections for existing post ad far as SEO goes since it will change the link structure?

  2. Would one need to them manually set up all the redirects after making this change or would that be automatically done?

  3. Since a that is a collection can only exist within that collection from what I am reading in the docs, how does it handle tags that come 2nd or 3rd if one has more than one tag on the post. I know it will obviously be shown under the url domain.com/collection/post-slug . So if a post thatā€™s in a collection can only be in that one location does that mean the location for any additional tags after the 1st one (which assigns the post to a collection) would be located as such domain.com/collection/tag2/post-slug

Sorry if I am not using the correct terminology for my question, but hopefully you can understand what I am asking.

And lastly,
4. Is collections the answer to organize content for the end user in such a way

If the 1st tag assigns the collection, can we use 2nd, 3rd & 4th tags we assign to a post to then display content as such and with such a locatio.

Example:
Post: 2 Day Rome Italy Travel Guide

1st Tag Travel Guides and assigns it to the travel guides collection.

Tag 2 On The Post: Europe
Tag 3 On The Post: Italy
Tag 4 On The Post: Rome

User experience I am aiming for would be
Page 1 Display A List Of All Main Collections they choose travel guides, then it takes them to page 2 which contains a list of all 7 continents and they chose Europe, page 3 contains all the countries in Europe and they chose Italy, to then reveal all the locations within Italy that I have guides for and they those Rome, which then shows all the post published for Rome.

Url structure
Domain.com/travel-guides/europe/italy/rome/2-days-in-rome-travel-guide

How many hours would it take someone with the skills to edit the theme to display content like this, so I can understand what cost I will be looking at.

I know creating collections is easy and doesnā€™t take much time at all, but I donā€™t know how long it would take someone to edit or create a custom theme or to add this functionality into my theme (taste theme).

Thanks

Yes, moving content without redirects is bad for SEO. Youā€™ll want to make a redirects file for any content that moves, and you can expect temporary weirdness in Google Search console anyway (itā€™ll be complaining that the page is a redirect rather than missing ā€“ which is better butā€¦)

Themes donā€™t control the routing, so a theme cannot create a url like /tag1/tag2/tag3.

Iā€™m not 110% sure, but I donā€™t think itā€™s possible to get routing set up generically as /tag1/tag2/tag3. You can write a specific route, but I donā€™t think you can sub in any tag value other than the first one, which is {primary_tag}.

Hierarchies in Ghost are complicated, because you canā€™t assign a tag to a parent tag. You can sort of fake it, like this:

(regional tags have a faked state attribute assigned to them)

or this:

(each post has an entire hierarchy of tags and Iā€™m reading it to build that tree structure on the fly)

or even this (has location tags and topic tags): https://citymyway.com

ā€¦but itā€™s sort of a pain. I keep thinking I should build a theme that fakes hierarchies, but I have yet to come up with a great generic way. Seems like every time needs a bespoke solutionā€¦

2 Likes

Hi @RyanF

I have a similar question: I have a separate page for my content in Chinese tagged with ā€˜cnā€™. However, I want the URL extension to remain /cn/, but to change the tag to ā€˜Chineseā€™, so my page does not look like this:

Here is my routes.yaml file:

routes:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: 'tag:-cn'
  /cn/:
    permalink: /cn/{slug}/
    template: index-cn
    filter: 'tag:cn'

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/
1 Like

You can change the tagā€™s name separately to its slug which I think is what you want to do if Iā€™m understanding correctly.

To do that you can click Tags in the Admin sidebar and find your ā€œcnā€ tag. After clicking on that to access the tag settings you can change the name field to ā€œChineseā€ and save.

Thanks so much Cathy.

So there is no way to structure a ghost site as follows

Travel Guides ā€”> Continent ā€”> Country ā€”> City

An then once they have landed on the city hierarchy it display all the guides we have posted for that city?

If I understood correctly what you said (Iā€™m timing all the way awake yet). So if itā€™s not possible, what would you recommend for your readers to be able to find the content the seek, I realize Organic traffic is irrelevant for this topic, but since we are membership sites, members will manually go to the site rather than google the site or google something hoping our site will pop up, so how does one make a members experience is the best by them knowing or having way to find something you may have posted a year ago.

Sorry I donā€™t know all the correct terminology, but hopefully you understand what I am saying.

The only thing j can think to do to make certain tags visible and easy explore is to use the tag url and paste that archive or tag url into your header so that the content is auto updated with each new post.