get list of tags of post

21 views
Skip to first unread message

oleg.pol...@gmail.com

unread,
Jul 16, 2019, 7:41:02 PM7/16/19
to JBake Users
Hello.

I have couple questions about tags.

1. How to get list of tags of CURRENT post, which are described (for example) as:
tags=tag_one,tag_two,tag_three

2. How to get list of tags of any post in cycle?
For example:

<#list posts as post>
<h2><a href="${post.uri}">${post.title}</a></h2>

<!-- next code doesn't work -->
<#list post.tags as tag>
${tag.name}
</#list>

<!-- next code also doesn't work -->
<#list post.tags.split(",") as tag>
${tag}
</#list>
</#list>

Frank Becker

unread,
Jul 27, 2019, 11:12:10 AM7/27/19
to JBake Users
Hi,


Am Mittwoch, 17. Juli 2019 01:41:02 UTC+2 schrieb oleg.pol...@gmail.com:
Hello.

I have couple questions about tags.

1. How to get list of tags of CURRENT post, which are described (for example) as:
tags=tag_one,tag_two,tag_three


Inside your page/post/custom template you can access the tags with content.tags. See  https://jbake.org/docs/latest/#page_post_custom

2. How to get list of tags of any post in cycle?
For example:

<#list posts as post>
    <h2><a href="${post.uri}">${post.title}</a></h2>

    <!-- next code doesn't work -->
    <#list post.tags as tag>
        ${tag.name}


This should work, but without .name.

    </#list>

    <!-- next code also doesn't work -->
    <#list post.tags.split(",") as tag>
        ${tag}


post.tags is a list you don't have to split here.

    </#list>
</#list>


Hope that helps.
Reply all
Reply to author
Forward
0 new messages