The Global Layout Data Tags will be used anywhere in your Blogger template code. This article is useful for Blogger developers who creating Blogger template.
List of Global Layout Data Tags
Blog Title
<data:blog.pageTitle/>
This tag will show your Blog Title. You can change value of this tag by access: Settings / Basic / click Edit link on Title field, type the title you want and click Save changes.
Page name
<data:blog.pageName/>
This tag will show your Page Title, in general, it’s your post title or page title you typed when publish.
Page type
<data:blog.pageType/>
This tag will show the type of current page. This tag has below values
- index – mean the current page is home, label, search page or all posts page (include home and its older posts pages).
- static_page – mean the current page is a static page
- item – mean the current page is a post.
- archive – mean the current page is time archive page
- error_page – mean the current page is 404 page.
* Notes:
- A preview page will have page type “item” but the URL is “homepageUrl” (data:blog.url == data:blog.homepageUrl)
- A label page will have data:blog.searchLabel == true
- A search page will have data:blog.searchQuery == true
- All posts page will have data:blog.title == data:blog.pageTitle or data:blog.pageName == ""
- Home page older posts is all posts page but have data:blog.url != data:blog.homepageUrl
Blog Description
<data:blog.metaDescription/>
This tag will show the description of your blog if the current page is home page, or show the description of post if its type is static_page or item To change the description for home page, access Settings / Search preferences. one Meta tags section, click Edit link on Description field, check Yes at Enable search description? option. Then input your blog description and click Save changes. To input the description for your post, before publish a post, look on right side, you will see Search Description option, click and input the snippet for the post.
BLOG URL
<data:blog.url/>
This tag will show the canonical URL of the current page. Canonical is current URI of the page without extend paramenters. Example: https://sneeit.com?id=100 => canonical URL = https://sneeit.com
Home URL
<data:blog.homepageUrl/>
This tag will show the home URL of your blog.
Blog encode
<data:blog.encoding/>
This tag will show the encoding that’s using in your blog, common is “UTF-8”. Language direction
<data:blog.languageDirection/>
This tag will show either “ltr” or “rtl” for left-to-right and right-to-left languages, respectively. This tag value will change base on the language that you set up for your blog.
Feed links
<data:blog.feedLinks/>
This tag is only effect on header of page (before </head> tag). The result of this code will like below:
<link rel="alternate" type="application/atom+xml" title="Sneeit - Atom" href="https://sneeit.com/feeds/posts/default" />
<link rel="alternate" type="application/rss+xml" title="Blogger Items - RSS" href="https://sneeit.com/feeds/posts/default?alt=rss" />
<link rel="service.post" type="application/atom+xml" title="Blogger Items - Atom" href="https://www.blogger.com/feeds/5248366312679450270/posts/default" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://www.blogger.com/rsd.g?blogID=5248366312679450270" />
Usage
Global Layout Data tags are xml codes that’re available to use in all place in a Blogger template code. You can you a tag as direct out to HTML code:
<data:blog.pageTitle/>
Or use in if condition like this
<b:if cond="data:blog.pageType == "index">Your stuff of code here</b:if>
Or use as an attribute of HTML element with expr: before the attribute name
<body exrp:class='data:blog.pageType'>
Note: the preview page will work similar as homepage URL but has type is item.