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.


10 months ago, 12 replies   developers   tags   Edit 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}}
{{#is.photo}}
  {{> tagged-photo}}
{{/is.photo}}
{{^is.photo}}
  {{> tagged-default}}
{{/is.photo}}
{{/tagged}}

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

{{#tagged}}

{{#is.photo}}
  {{> tagged-photo}}
{{/is.photo}}

{{#is.blog}}
  {{> tagged-blog}}
{{/is.blog}}

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

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 3 years ago · Edit answer

I recently fixed a bug with the way the {{#tagged}} object rendered so the answer above should now actually work – sorry about this.

Answered 10 months ago · Edit answer