Fetching and Displaying Labels

Show post categories by using the Label widget or looping through data.

In Blogger, "Labels" are used as categories or tags. You can display them as a list for the whole blog or show the specific labels applied to a single post.

Method 1: The Label Widget

The simplest way. Add a Label widget from the Layout dashboard. It will automatically generate a list of all labels used on your blog, with links to the respective category pages.

Method 2: Looping Through Post Labels

To display the labels for a *specific post*, you need to use a loop inside the `Blog1` widget. This is very common for post meta sections.

Code Examples

xmlLooping Through Post Labels
1
2
3
4
5
6
7
8
9
<!-- This code goes inside the post loop in the Blog1 widget -->
<b:if cond='data:post.labels'>
<div class='post-labels'>
<span>Posted in:</span>
<b:loop values='data:post.labels' var='label'>
<a expr:href='data:label.url' rel='tag'><data:label.name/></a><b:if cond='!data:label.isLast'>, </b:if>
</b:loop>
</div>
</b:if>

Was this lesson helpful?

Have feedback, found an issue, or have a suggestion? Let us know!