how to get tag.uri given a tag name ?

16 views
Skip to first unread message

max.an...@gmail.com

unread,
Nov 9, 2018, 6:48:42 AM11/9/18
to JBake Users
Hi,


Is there a way given a tag name (as string) to lookup the tag model so I can get the uri field ?

I thought something like ${tags['mytag'].uri} would work but tags is just an iterable collection.

thank you

max.an...@gmail.com

unread,
Nov 9, 2018, 2:17:05 PM11/9/18
to JBake Users

for context its my attempt to see if I can workaround or find solution to why content.rootpath with tag.path=blog/tags result in a bad result.

opened issue at https://github.com/jbake-org/jbake/issues/563

Jonathan Bullock

unread,
Nov 10, 2018, 5:54:39 PM11/10/18
to JBake Users
Unfortunately not an easy way no. I'm struggling to remember if there was a reason why this data type was selected too.

Max Rydahl Andersen

unread,
Nov 10, 2018, 6:54:22 PM11/10/18
to Jonathan Bullock, JBake Users
Hi Jonathan,

How does one generate tags pages with links to right uri without that info ? Particularly when tag.path isn’t just one level deep ?
--
You received this message because you are subscribed to a topic in the Google Groups "JBake Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jbake-user/1pruud3j3T8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jbake-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonathan Bullock

unread,
Nov 11, 2018, 4:38:19 AM11/11/18
to Max Rydahl Andersen, jbake...@googlegroups.com
You can do it by looping through all the values in that collection to find the match for the tag value you have, but it's not ideal.

Hmm... actually let me double check I'm on the same page... are you trying to access this tags data model from the template of content (i.e. page/post/custom) so to provide a link to the tag page? Or are you accessing it from the tags template so to provide links to the content attributed to that tag?

Jon

Max Rydahl Andersen

unread,
Nov 12, 2018, 4:10:19 AM11/12/18
to Jonathan Bullock, jbake...@googlegroups.com
Hi Jonathan,

I’m on a post page trying to make the right link to its tag.

Manik Magar

unread,
Nov 12, 2018, 7:52:29 AM11/12/18
to Max Rydahl Andersen, Jonathan Bullock, Jbake-User
Hi Max,

Maybe this can help, see this code for how I am building tags in freemarker template- https://github.com/manikmagar/jbake-phlat-theme/blob/master/templates/post/content-single.ftl#L8

My tags.path is default so I have hard coded it to build the path. But that hard coded value can be replaced with ${config.tags_path} to pick the value from configuration. 


Regards,
Manik


You received this message because you are subscribed to the Google Groups "JBake Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbake-user+...@googlegroups.com.

Max Rydahl Andersen

unread,
Nov 12, 2018, 8:26:46 AM11/12/18
to Manik Magar, Jonathan Bullock, Jbake-User
Hi Manik,

Yeah I’ve done similar but it fails when trying to put it in for example /blogs/tags
Reply all
Reply to author
Forward
0 new messages