I am currently trying to divide my Ghost blog (version 3.12.1) into a “blog” and a “status” section. I had the idea to use internal tags to distinguish between the regular blog posts, and the shorter status posts that get rendered differently. Following that idea, I created the following routes.yaml file:
routes:
/:
data: page.home
template: home
collections:
/status/:
permalink: /status/{id}/
template: status
filter: primary_tag:hash-status
data: tag.hash-status
/posts/:
permalink: /post/{slug}/
template: index
filter: primary_tag:hash-post
data: tag.hash-post
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
Unfortunately that does not seem to work. Even when I assign the correct tags to the posts, I get a 404 for both URLs, “/status/” and “/posts/”. It seems that the foreach loop comes up empty:
When I test it with regular, non-internal tags, everything works as expected. But then I would end up with a visible “post” and “status” tag – what I don’t really want.
I was first thinking of using {{#get}}...{{/get}} to query the posts, as a workaround, but that is missing the pagination, which would also be not an option for me.
Am I doing something wrong, or is what I am trying to achieve currently not possible? Any input welcome. Thanks!
Just tested your routing on my end. Here is how I got it working.
It seems like 404 is related with data: tag.hash-status. When I remove the line, it doesn’t throw 404. I assume it’s because internal tags don’t have data (name, slug and description) like regular tags.
Then I updated the filter to use tag:hash-status instead of primary_tag.
Awesome, that did it! Thank you very much. Unfortunately, this causes another problem. Since it does not use the data for meta_title and meta_description, I now get “My awesome blog (Page n)” as a title on the index page.
Any idea how to get rid of it, without hardcoding the values in HTML?
I’m afraid there might not be any other way than hardcoding them when you’re using internal tags. How about using regular tags and hiding the tags with CSS?
Thanks for your input! I really appreciated your quick answers and your thoughts
I thought about using CSS, too. But that would just be a cosmetic fix and a bit hacky. They would still be accessible under https://myblog.com/tag/status/ and also be visible when I list all the tags on the post page as well.
Hey @jbfriedrich, I was totally wrong with the assumption below. It still doesn’t work, but it doesn’t seem like the reason. Internal tags have as much data as regular tags. There must be another reason why it didn’t work.
Yes, that is also what I figured. The internal tags are supposed to be no different from the “normal” tags, from what I could read from the documentation and what I found on the web. I am not sure if it’s worth to open a GitHub issue. I don’t want to create unnecessary work for the Ghost Team.
Rather than using tag data I’m using page data, which will give you a bit more control. You’ll need to modify the status.hbs template to make sure the content of the page is being exposed correctly. I’m also using the filters to mirror each other, so the status page only shows posts with the internal status tag and the home page show ever other type of post. Bit more streamlined than adding an internal tag to every single post.
Hi @DavidDarnes! Thanks a lot for your quick input, it is very much appreciated. I tried using a page, too, but it makes things very messy and sometimes I get an empty page, where the posts are supposed to be. It was a wild ride with a lot of testing the last couple of days .
Just in general, it should work only with tags, shouldn’t it? Are @minimaluminium and I reading the documentation wrong? I am trying to understand whats going on and why the data from the public tags can be used, but the private/internal tags fail to render, even though you can specify a description, meta data and title etc. in the Ghost admin UI.
The routing feature might need some more love. Do you think it would be beneficial to create a GitHub issue for this? There is also another issue that is related. The link to the RSS is not generated properly in {{ghost_head}} when I use my routes.yaml file. It creates a link without a proper href to the RSS feed. The RSS feed itself works fine, but as its not linked properly in the header. Tools have a problem finding the feed.
That could be possible, I won’t rule that out firsthand. I would need to test again .
But the question still remains: Is the internal tag behaviour that we experience here intentional, or is it a bug? If it is a bug, would a bug report on Github help, or would that be counter-productive as the team is aware and its on an internal list somewhere?
hi @jbfriedrich, did you eventually file an issue for this? I’ve been looking into the repo but I could not find anything related to this topic. I am facing exactly your problem, not being able to fetch the meta_title and meta_description on the index page for collections. I’ve been trying both with internal and public tags, but it doesn’t make any difference. Here’s my routes.yaml, if it is of any help for the Ghost staff:
Hey guys! Sorry for the late reply, I did not have a chance yet to create that issue . Sorry about that, but it has been a couple of busy weeks due to current events and work that came in the way.
I was just able to finish my “theme” and set up the blog the way I want it to. Next step is to gather all the info and file the issue on Github. My plan is to do it this week, if nothing unforseen happens in the meantime. Sorry again!
Hey David, I’m working through the exact issue outlined in this thread, but I think I’m getting caught up on this line in your directions. What does it mean to expose the content of the page correctly?
In my case, the desired result is simple. I have a blog, which I populate with posts tagged #blog (slug being hash-blog).
This is driving me nuts. Ideally, I’d be able to use data: tag.hash-blog and pull the meta title and description as they are set in the CMS. I see there may or may not be an open issue for that. In the meantime, any help you can lend to get your workaround functioning would be great!
Hmm, my first guess is that you’ve created a page called blog with the same slug as the collection name. This might be why there’s a redirect loop happening, because it’s not sure whether to show the page or the collection page. Try changing the page slug to blogpage and then assigning the post data to page.blogpage.
You may also need to add a redirect in for the blogpage URL so it redirects to blog, however Ghost may sort that for you (I can’t remember off the top of my head).