I’ve set up my routes.yaml file so that a bunch of translated posts appear in their own channel rather than the main post listing. Problem is, and as far as I can tell, I can’t target those posts on their index pages for some specific coding.
In particular, and like my main blog feed, I’d like to have the {{title}}
s in the listings have links to the actual post(s), while the {{title}}
s of the individual posts don’t have links (to themselves).
This is what the main blog feed uses:
<h2>
{{#is "index, tag"}}
<a itemprop="url" href="{{url}}" title="{{title}}">{{title}}</a>
{{else}}
{{title}}
{{/is}}
</h2>
Problem is, the index
portion of {{#is "index, tag"}}
only recognizes the index of the main post listing, not the indexes of the channels I’ve set up. As a result, the {{title}}
s of the translation channel indexes don’t get links to the actual posts.
I tried this:
{{#has tag="#Translations"}}
<h2>
{{#if post}}
{{title}}
{{else}}
<a itemprop="url" href="{{url}}" title="{{title}}">{{title}}</a>
{{/if}}
</h2>
{{/has}}
…but that doesn’t work because the listings in the indexes are regarded as posts as well (meaning the {{title}}
s on neither the indexes nor the actual posts still don’t have the link).
According to what I gather from the “Contexts” portion on the docs page it’s not possible to target an index listing that isn’t the main post listing. Am I correct in this, meaning there’s no way to do what I’m after and I should just go with the following, resulting in the titles of the actual posts having links to themselves?
{{#has tag="#Translations"}}
<h2>
<a itemprop="url" href="{{url}}" title="{{title}}">{{title}}</a>
</h2>
{{/has}}
This is my routes.yaml file in case it’s of any consequence:
routes:
collections:
/:
permalink: /{slug}/
template: index
filter: tags:-[francais,hrvatski,italiano,turkce]
/francais/:
permalink: /francais/{slug}/
template: index
filter: primary_tag:francais
/hrvatski/:
permalink: /hrvatski/{slug}/
template: index
filter: primary_tag:hrvatski
/italiano/:
permalink: /italiano/{slug}/
template: index
filter: primary_tag:italiano
/turkce/:
permalink: /turkce/{slug}/
template: index
filter: primary_tag:turkce
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/