Blog listing and blog post templates can be used to customize the appearance of a site’s blog.
templateType: blog
annotation to the top of your template file. When using one template to render both, you’ll use an if statement that evaluates whether the user is looking at a listing page or an individual post. If you are using the drag and drop design manager layouts, this if
statement is built into the UI of blog content module buttons.
By using the if is_listing_view
statement, you can write your post and listing code separately.
templateType: blog
annotation at the top of the one template, include the following annotations at the top of your two templates:
templateType: blog_post
templateType: blog_listing
is_listing_view
check is not required. Instead, you’ll manually select separate templates within the account’s blog settings.
You can also migrate an existing unified blog template to be either a blog post template or blog listing template.
templateType: blog_listing
annotation makes the template available for selection under blog settings specifically for the listing view. With this template type, content creators can also edit the listing page within the page editor. By also including drag and drop areas in the template, modules can be added and removed in the page editor like they can for other CMS pages. Check out the CMS boilerplate blog templates to see examples of including drag and drop areas.
The listing of posts is generated by a for loop that iterates through your blog posts. contents
is a predefined sequence of content that contains all the posts contained in that blog.
if
statements to conditionally render content for each type of page.
if blog_author
statement. This statement evaluates as true when viewing an author’s page, which lists the posts published by the author. The boilerplate template includes the author’s name, bio, and social media accounts.
if tag
statement to only render code on a blog topic listing page, which visitors can see when clicking a blog topic on your site. The example below is a snippet that uses the page title variable to automatically print the tag name at the top of a tag listing page.
/all
added to the end of the path.if not simple_list_page
statement to determine what to render in a simple versus regular listing. A simplified version of this statement is shown below.
if
statement uses reverse logic, which means that the else
defines the simple listing view. Optionally, you could use an unless statement instead.Content
is a predefined object of data that contains information about the requested blog post. Boilerplate posts are rendered with the following markup:
content
data.