Hi, every time I add new posts to a collection, all the existing posts duplicate multiple times. It’s really weird because the homepage looks perfectly normal. Any help would be greatly appreciated!
This is probably an error in the logic of the theme. If you switch to one of the official themes, does the problem disappear? Which theme is this?
Thanks for your reply. I was using the “edge-v1.0.0” theme. Then, I switch to one of the official themes, all my customizations were gone and posts disappeared from the collections. When I switched back to “edge-v1.0.0” and re-uploaded my old routes.yaml file, posts still disappeared from the collections.
Any tips on how to fix it would be greatly appreciated!
Could you please share the content of your routes.yaml
, there might be some mistakes in it.
Thanks for you help.
routes:
collections:
/:
permalink: /{slug}/
template: index
/ux-ui/:
permalink: /ux-ui/{slug}/
template: ux-ui
/printing/:
permalink: /printing/{slug}/
template: printing
/photography/:
permalink: /photography/{slug}/
template: photography
/packaging/:
permalink: /packaging/{slug}/
template: packaging
/logo/:
permalink: /logo/{slug}/
template: logo
/other/:
permalink: /other/{slug}/
template: other
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
You’ve created many templates for collections, let’s debug this step by step, what do you write in the “photography” template?
When I switched back to “edge-v1.0.0” and re-uploaded my old routes.yaml file, posts still disappeared from the collections.
Is this issue persisting? If so, check how many version of “edge” theme are installed in Ghost settings => design & branding => change theme => installed
Thanks for your reply.
This issue is persisting. Only one version of “edge” theme are installed.
what I write in the “photography” template:
{{!< default}}
Your routes.yaml is a bit odd. You’d normally want a filter on each collection, indicating which posts go into that collection. And because posts go into the first collection they match, you’ll want to think carefully about order, if it’s possible they might match multiple collections. (This is a good reason to use the primary_tag, and to put the /:
collection last…)
So like:
/photography/:
permalink: /photography/{slug}/
template: photography
filter: primary_tag: photography
Then, in photography.hbs, the posts will already be available and will already be filtered, so you can reduce it to:
{{!< default}}
{{#foreach posts}}
{{> "loop"}}
{{else}}
There is not post
{{/foreach}}
{{pagination}}
It looks like the custom template is very similar to the “index” template except it filters by a specified primary tag.
The reason why your collections don’t work is that: a post can only be in one collection, your first collection is “/”, which includes all posts, meaning all posts are in the first collection, and not visible in other collections.
Based on your website screenshot, I think “channel” is a better choice for you. Check this link for more details:
You don’t need to create custom templates for each custom URL, the “index” template should handle your needs.
I just wanted to say a big thank you for your help with my problem.
Your advice was incredibly helpful, and I really appreciate you taking the time to assist me. You’re a lifesaver!
I just wanted to say a big thank you for your help with my problem.
Your advice was incredibly helpful, and I really appreciate you taking the time to assist me. You’re a lifesaver!