Add description to tag?
Is there a way to add a description to a tag so that when viewing domain.com/tagged/tagname
a block of text could be included?
There isn't an elegant way to accomplish this right now but I want to extend the template system to make this possible. Here is the hacky solution:
You can embed the HTML contents of a post or page from your folder, using the following code in one of your template views:
{{> /pages/tags.txt}}
So I would use this and a CSS trick to selectively display a part of a page.For example, doing this in your template's tagged.html:
<div class="intro"> {{> /pages/tags.txt}} </div>
<style type="text/css">.intro :not(.{{tag}}) {display:none} </style>
And then this in your folder's pages/tags.txt:
Menu: no
<p class="apple">
This is the introduction shown for the tag apple.
</p>
<p class="orange">
This is the introduction shown for the tag orange.
</p>
Does that work? I recognize this is not quite ideal – I'm still working on the template engine. Eventually I'd like to be able to do something like this:
{{> /pages/tags/{tag}.txt}}
But that kind of dynamic partial-template lookup isn't yet built. Anyway, please let me know if you have any thoughts, feedback or questions about this or anything else.
Answered 3 years ago · Edit answerWould it be possible to enable use of {{tagged}} on the tags page? That way we can do stuff like:
{{#tagged.apple}}
<h2>These stories are all about why #apples are wonderfully healthy.</h2>
{{/tagged.apple}}
{{^tagged.orange}}
<h2>No #oranges, please!</h2>
{{/tagged.orange}}
I'm using Blot as a blog and digital garden so I'd like to display different layouts for specific tags.
For example, the usual blog tags will display the normal way on the tagged.html page (headlines only). For things tagged for the Garden, I'd like the tags page to show in blog style format rather than headlines.
{{#entries}}
{{^tagged.garden}}
<a href="{{url}}">{{title}}</a>
<span class="small">{{date}}</span>
<br />
{{/tagged.garden}}
{{#tagged.garden}}
<h2><a href="{{url}}">{{title}}</a></h2>
{{body}}
{{/tagged.garden}}
{{/entries}}
This would save a great deal of work having to make multiple .txt files, etc. etc. per the prior question.
On a side-note, can tagged.html pages have pagination enabled, please? Sometimes they get really long.
Answered 2 years ago · Edit answerPagination on the tagged pages isn't ready yet, if you send us an email registering your interest in this feature we'll let you know when it is.
You can already use {{#tagged}}...{{/tagged}}
on the tags page! Your example should work, if it doesn't please email us a link to a page which uses the code above but isn't working as expected and we'll work out what's going on
The first example doesn't work well because it repeats multiple times and won't work outside the {{entries}} code.
I was trying to use it to have descriptions for each tag. If this won't work, maybe a feature request for something like
{{#tag.apples}}
These tags cater to different types of apple trees.
{{/tag.apples}}
Answered 2 years ago ·
Edit answer
Fair enough, to avoid it repeating inside the entries block try this:
{{#entries}}
{{#first}}
{{#tagged.garden}}
...
{{/tagged.garden}}
{{/first}}
{{/entries}}
Answered 2 years ago ·
Edit answer
David, any updates on this one?
The first method worked for me, but it using one will create too many hidden
lines on a tagged page in my case (many tags, https://lev.lc/tags) which is neither elegant nor is it good for the page load.
The last method didn't work for me, it creates strange anomalities such as a tag intro for one tag appearing when navigating to another tag's page. Perhaps instead of waiting for the improvement of templating engine it is possible to get around with how blot treats the folder files, for example:
files with
link:
instruction aimed attagged/xxx
will render the files content into html before running the template instruction for corresponding "xxx" tag, or betteruse
/tags' file folder and treat
tagname.md` as a description for the corresponding tagged page