I am trying to hide posts tagged links
on my homepage. And, I am trying to create a new domain.com/links/
URL where posts tagged links
appear.
When I publish posts with the tag links
and visit domain.com/tag/links
I see a list of the posts with that tag but when I click on any of the posts I get a 404 error. If I remove the tag links
on any of those posts then the posts are visible.
I also renamed default.hbs
which is my homepage template to links.template.hbs
and restarted the server. When I visit domain.com/links
I get a 404 error.
Any idea how I can achieve all of these things:
- Hide
link
tags on the homepage (this is working using filter: tag:-links below)
- Show posts that have the
link
tag that are linked from domain.com/tag/links
(this is not working)
- Show a default page at
domain.com/links
that loads posts with the link
tag (this is not working, should I be using something other than default.hbs as the template?)
- Show posts that have the
link
at domain.com/links/{year}/{month}/{day}/{slug}/
(this is not working)
I have set up routes.yaml
below and configured it as follows:
routes:
collections:
/:
permalink: /{year}/{month}/{day}/{slug}/
template: index
filter: tag:-links
/links/:
permalink: /links/{year}/{month}/{day}/{slug}/
template: links.template
filter: primary_tag:links
data: tag.links
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
Update:
- Working
Hide link
tags on the homepage (this is working using filter: tag:-links below)
- Show posts that have the
link
tag that are linked from domain.com/tag/links
(this is not working)
Show a default page at domain.com/links
that loads posts with the link
tag (this is not working, should I be using something other than default.hbs as the template?) I suspect I just needed to post content with the tag for it to start working and might have had some prior tag naming conflict
Show posts that have the link
at domain.com/links/{year}/{month}/{day}/{slug}/
(this is not working) I suspect this is related to not having posted content yet or having a tag naming conflict
I duplicated index.hbs and renamed it links.hbs (and made some minor changes)
I modified routes.yaml a little bit but doubt anything in here changed things. I suspect I had some issues because I was using a tag with an emoji. Of course, blame the happy icons.
routes:
collections:
/:
permalink: /{year}/{month}/{day}/{slug}/
template: index
filter: tag:-links
/links/:
permalink: /links/{year}/{month}/{day}/{slug}/
template: links
filter: primary_tag:links
data: tag.links
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
I don’t think you need the data entry under links.
Your two filters should match (except the -) or else you’ll get posts with nowhere to go.
Definitely create some test content with and without the tag - routes aren’t going to work without it.
On 3) everything uses default.hbs. As I think you discovered, you can duplicate index.hbs if you want a second index template
1 Like
Thanks, Cathy! One thing I am still trying to figure out is how to create a custom RSS feed with just the posts tagged with links.
Currently, no matter what I seem to do I get all posts on my site appearing in my rss feed even when rss.hbs contains {{#get "posts" filter="tag:links" include="authors,tags"}}
Based on the way the routes.yaml is set up and the RSS feed is generated I was expecting that the RSS would exclusively feature posts that are tagged with “links”, and that other posts with different tags would not be part of the feed. But, that is not the case, I get every tag on the site.
routes:
/links/rss/:
template: links/rss
content_type: text/xml
collections:
/:
permalink: /{year}/{month}/{day}/{slug}/
template: index
filter: tag:-links
/links/:
permalink: /links/{year}/{month}/{day}/{slug}/
template: links
filter: tag:links
data: tag.links
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
For what I presume are good reasons I am realizing that Ghost has some very strict rules which I keep bumping into no matter what I try to do. I’d like to configure Ghost to do the following:
-
domain.com hosts all posts except for those tagged links
featuring an rss feed that does not include posts tagged with links
-
domain.com/links host a custom page that rolls up all links by date in reverse chronological order with an rss feed that only includes posts tagged with links
-
domain.com/tags/anything_but_links can be an rss feed that only includes posts tagged with the tag anything_but_links
I seem to be struggling to figure out how to support #2 while also supporting #1 any help/advice is greatly appreciated.