How can I add a recent blog archive into any custom page template

I'm having trouble on getting a blog archive onto one of my custom page templates that showcases authors.

Problem

Isaish Brown, a customer on BigCommerce mentioned:

I'm having trouble on getting a blog archive onto one of my custom page templates that showcases authors. I have inserted the frontmatter for the blog and handlebar function into my custom page template:

    ---
    blog:
        posts:
            limit: 12
            pages: 2
            summary: 500
    ---
    {{#partial "page"}}
    <div class="page page-normal">
        <main class="page-content halo-page-content">
            {{#if page.sub_pages}}
                <nav class="navBar navBar--sub">
                    <ul class="navBar-section account-navigation">
                    {{#each page.sub_pages}}
                        <li class="navBar-item"><a class="navBar-action" href="{{url}}">{{title}}</a></li>
                    {{/each}}
                    </ul>
                </nav>  
            {{/if}}
            <div class="halo-description">
                {{#replace '%%Syndicate%%' page.content}}
                    {{> components/page/rss_feed}}
                {{else}}
                    {{{page.content}}}
                {{/replace}}
                {{{region name="page_builder_content"}}}
     
                <h3>Latest Post</h3>
                {{#each blog.posts}}
                    {{> components/blog/post post=this}}
                {{/each}}
            </div>
        </main>
    </div>
    {{/partial}}
     
    {{> layout/base}}

Solution

To get Recent Blogs working in a custom Page template, you'll want to update the YAML and code to this:

    ---
    blog:
      recent_posts:
        limit: 4
    ---
     
    {{#each blog.recent_posts}}
            {{> components/blog/post post=this theme_settings=../theme_settings}}
    {{/each}}

To see if your YAML populated in local development, you can run '?debug=context' parameter in the url to output the resulting json.

Tags

BigCommerce

Dated

Created: May 30, 2025

Updated: May 30, 2025

Brod Solutions Logo
Your Brand's Missing Link

American Made

© 2012-2025 Brod Solutions, All rights reserved.