Log in Sign up

Specific Tag Views

Is there a way to creat specific views that the blog engine will access when a visitor goes to a /tagged/keyword url?

Example.

I’d love to be able to make a tagged-photos.html view with specific markup and have the blog engine know to load this when someone goes to the /tagged/photos url.

If a tag specific view does not exist, the default tagged.html would be used.

I know I can make a view, filter it on a specific tag, and then bind that view to a specific short url /photos through the json file, but I’m wondering if there’s a more fluid/less clunky way.

2 replies Asked Oct 13 '21 at 15:05 · Improve this question

Yes, but there will still be filtering involved. You’ll need three views:

  • tagged.html
  • tagged-default.html
  • tagged-photo.html

Then add the following to tagged.html:

{{#tagged.photo}}
  {{> tagged-photo}}
{{/tagged.photo}}
{{^tagged.photo}}
  {{> tagged-default}}
{{/tagged.photo}}

If you want to add other custom pages, you can stack them like so:

{{#tagged.photo}}
  {{> tagged-photo}}
{{/tagged.photo}}
{{#tagged.blog}}
  {{> tagged-blog}}
{{/tagged.blog}}
{{^tagged.photo}}
{{^tagged.blog}}
  {{> tagged-default}}
{{/tagged.blog}}
{{/tagged.photo}}

Does that make sense? It’s a little bit clumsy but should get the job done! I would eventually like to add parameterised embedding, e.g.

{{> {tag}.html}}

But we’re not there yet… Please let me know if you have any questions about this or anything else. Am always happy to hear any feedback!

Answered Oct 13 '21 at 18:23 · Improve this answer

I came to a solution similar to this as I thought through it more.

For the use case I’m toying with, this is easily sustainable and manageable. Thanks for putting this out there.

I guess, given a selling point of Mustache is its simplicity, that there would be a certain level of clumsiness to a process with a bit more logic.

Answered Oct 14 '21 at 15:46 · Improve this answer

Please, log in to add a reply.