Routes and Collections - No SEO data and template conflicts

This is a little complicated to explain, so please bare with me.

I have some blog posts about schools. I have these setup to display in a collection called schools. This is the routes file:

collections:
  /schools/:
    permalink: /schools/{slug}/
    template: schools
    filter: tag:schools
    order: title ASC 

This all works great, but the collection doesn’t have any meta content, facebook opengraph data or anything that can be searched by crawlers.

Is this the correct way that Collections work? Do they really not have any data for Google to use?

To help solve this problem, I found what I thought was a solution.

Based on this idea, I updated my routes file to be:

routes:
  /schools/:
    controller: channel
    template: schools
    filter: tag:schools
    data: page.schools

collections:
  /schools/:
    permalink: /schools/{slug}/
    template: schools
    filter: tag:schools
    order: title ASC 

This actually fixed the SEO issue and the title, but it completely breaks the load more functionality so my page can only load 8 posts and thats it. The whole pagination/load more functionality doesn’t work when I add the routes option above.

Does anyone have any ideas how I can fix this issue and get Collections to show SEO data and not break everything.

cheers
Andrew

Not sure if this is going to help, but I tried accessing the page data directly from the collection, but it still breaks the ability to load more posts. Absolutely devastated about this. 1 months work and what is the point if Google can’t find the page…

collections:
  /schools/:
    permalink: /schools/{slug}/
    template: schools
    filter: tag:schools
    order: title ASC 
    data: page.schools

Hi @andrewmc, sorry you’re having trouble with this. Couple of questions:

  • Do you have an example of this issue live somewhere?
  • Is this ‘school’ collection made up of pages and not posts?

Edit: You should probably remove the routes definition as it might be conflicting with the collection definition. More info can be found here:

Thanks for your reply @DavidDarnes

  1. Unfortunately site is local at the moment.
  2. all posts.

At the moment the only way I can resolve the issues is to create a custom default.hbs file. This allows me to hardcode the page title and seo data. It also has allowed me to keep the load more script working.

No idea how else to solve this but disabling the collection is not possible, plus if I just use the routes option I still run into load more issues.

Note: Using nurui theme, not casper.

Have you tried keeping the updated collection with the data: page.schools but removing the routes definition?

Yeah, unfortunately I did try pretty much every possible combination… no luck.

Hmm, that’s not good. I can see that you’ve also opened a support issue. If we can’t get this resolved here then it might be best to switch to the support ticket.

Are you at all able to share what you have so far? If it’s not the conflict between routes and collections, which I feel like it most likely is, then it might be the theme not catering for infinite loading. Do you get any errors when scrolling to the bottom of the page? It’s very hard to debug this without seeing it

Hi David, can you tell me if by setting up collections what Schema Ghost includes into the code? Do you have an example I can see that shows the collection of post so I can see the code?

Thanks

Sorry, I’m not sure I understand what you’re asking for? If you want to see what Ghost produces when you create a custom collection you might want to set up a local version to try it for yourself