Your sites Log in Sign up Menu

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?


2 years ago, 5 replies   Improve this question

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 2 years ago · Improve this answer

Would 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 · Improve this answer

Pagination 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

Answered 2 years ago · Improve this answer

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 · Improve this 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 · Improve this answer