I would like to print tags that related with post / page with Jbake. But, after read the JBake documentation, especially for Data Model documentation so far I'm aware about:
- alltags
- tags
- tagged_posts
- tagged_documents
But, among those list there is no data model for tags that specific to post / page. It's possible to print tags specific to post / page?
I'm using:
- JBake version 2.7.0-rc.4
- Apache Freemarker as the template engine
After do trial and error finally I could list all tags from post / page.
JBake documentation for data model is only documented for global data model, so listed below model is for global use and is not what I want.
The tags for post / page is actually exist within
contentdata model. You can access it with${content.tags}, this will list all tags that related with post / page that you want.Now, to print it is the tricky part. Because the
tagskey withincontentmodel is only exist withinpost/pagetemplate.Print tags on
post/pagetemplate.List all post / page tags is easier when you're working under
post/pagetemplate. What you need to do is iterate thecontent.tags.Print tags outside
post/pagetemplate.This situation is when I need to generate
<meta name="keywords" content="" />on the html head section. I need special handling when the meta keywords rendered outsidepost/pagetemplate, for exampleindex.html.Because when not in
post/pagetemplate thecontentdata model only contains two keys:rootpathandtype. So, need special handling like below: