AOV.aiBlack Friday ads cost more. Get more from each order with a free gift.BFCM ads cost more. Get more from each order. Use code FG_BFCM30.Claim 30% OFF

Insert a Layout, Collection and Blog to a Static Site

Sam NguyenUpdated 7 min read
Summarize this post with AI

There might be instances where you need to integrate elements like layouts, collections, and blogs into a static site within your Shopify environment. This could be for creating custom landing pages, unique content sections, or even integrating a blog within a specific page.

This guide will convert a free HTML 5 template into a Jekyll site, offering a blend of customization and code editing techniques to solve your problems in a few minutes.

Let's get started!

Related Posts:

How to insert a layout, collection, and blog to a static site

1. Setup

Step 1: Download and setup your theme

In this instruction, we will be using the theme called Creative. After the theme Creative is downloaded, you have to unzip it, navigate to the directory in the terminal then run jekyll serve.

$ cd ~/Downloads/creative # or wherever you've unzipped the template
$ jekyll serve

Step 2: Open your site

To open and see your site, open your browser then navigate to http://localhost:4000 .

open your site

2. Layouts

Since it’s a four-page static site and the header, navigation, and footer of each page are repeated, we need to reduce this repetition with a layout.

Step 1: Create /_layouts/default.html

In this step, the first thing to do is to create /_layouts/default.html and copy the contents of index.html into it.

Next, replace the content in the layout that changes between pages with placeholder variable. You also need to replace all the contents of <title> with {{ page.title }}, which helps you to easily change it on each page.


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Creative - {{ page.title }}</title>
    <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css">
    <!-- Custom Fonts -->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css" type="text/css">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="/css/creative.css" type="text/css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <nav>
      <div>
        <!-- Brand and toggle get grouped for better mobile display -->
        <div>
          <button type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
          <span>Toggle navigation</span>
          <span></span>
          <span></span>
          <span></span>
          </button>
          <a href="/">Start Bootstrap</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div>
          <ul>
            <li>
              <a href="/about.html">About</a>
            </li>
            <li>
              <a href="/services.html">Services</a>
            </li>
            <li>
              <a href="/portfolio.html">Portfolio</a>
            </li>
          </ul>
        </div>
        <!-- /.navbar-collapse -->
      </div>
      <!-- /.container-fluid -->
    </nav>
    {{ content }}
    <section>
      <div>
        <div>
          <div>
            <h2>Let's Get In Touch!</h2>
            <hr>
            <p>Ready to start your next project with us? That's great! Give us a call or send us an email and we will get back to you as soon as possible!</p>
          </div>
          <div>
            <i></i>
            <p>123-456-6789</p>
          </div>
          <div>
            <i data-wow-delay=".1s"></i>
            <p><a href="mailto:[email protected]">[email protected]</a></p>
          </div>
        </div>
      </div>
    </section>
    <!-- jQuery -->
    <script src="/js/jquery.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="/js/bootstrap.min.js"></script>
  </body>
</html>

Step 2: Remove the HTML content

Next, you are now able to load the default layout on index.html and set a title in the front matter. After that, you can remove the HTML content in the layout.


---
layout: default
title: A Bootstrap theme
---
<header>
  <div>
    <div>
      <h1>Your Favorite Source of Free Bootstrap Themes</h1>
      <hr>
      <p>Start Bootstrap can help you build better websites using the Bootstrap CSS framework! Just download your template and start going, no strings attached!</p>
      <a href="/about.html">Find Out More</a>
    </div>
  </div>
</header>
<aside>
  <div>
    <div>
      <h2>Free Download at Start Bootstrap!</h2>
      <a href="/services.html">Download Now!</a>
    </div>
  </div>
</aside>

Step 3: Fix up the other pages

In this step, you have to fix up about.html, services.html, and portfolio.html which all have a block of HTML for the heading.


...
<section>
  <div>
    <h1>About</h1>
  </div>
</section>
...

fix up other pages

So as to reduce the repetition in the source code of every page, creating another layout that inherits from the _layouts/default.html is the next thing you should do.

Following the content below, let’s create _layouts/page.html.


---
layout: default
---
<section>
  <div>
    <h1>{{ page.title }}</h1>
  </div>
</section>

{{ content }}

This layout can now be used in about.html, services.html and portfolio.html without repeating source code. This is an example of how about.html looks like:


---
layout: page
title: About
---
<section>
  <div>
    <div>
      <div>
        <h2>We've got what you need!</h2>
        <hr>
        <p>Start Bootstrap has everything you need to get your new website up and running in no time! All of the templates and themes on Start Bootstrap are open source, free to download, and easy to use. No strings attached!</p>
        <a href="#">Get Started!</a>
      </div>
    </div>
  </div>
</section>

3. Collection

In portfolio.html, each portfolio item has an image, category and project name, and the rest of the code is repeated. To avoid repeating the code, we use a collection.

<div>
  <a href="#">
    <img src="/img/portfolio/1.jpg" alt="">
    <div>
      <div>
        <div>
          Category
        </div>
        <div>
          Project Name
        </div>
      </div>
    </div>
  </a>
</div>

Step 1: Create _config.yml and set up a collection

The first thing to do is to create _config.yml and set up a collection.

collections:
  portfolio:

Keep in mind that when updating _config.yml, you have to restart Jekyll so that the changes take effect.

Step 2: Create a _portfolio directory and add portfolio items

After creating _config.yml and setting up a collection, you can now create a _portfolio directory and add six portfolio items. Each portfolio item includes image_path, category, link, and project_name in the front matter. This is an example of a portfolio item for work that we did for Google – _portfolio/google.md.


---
image_path: /img/portfolio/1.jpg
category: Web Design
project_name: Google
link: https://google.com
---

Step 3: Loop over collection documents and output item details

To finish adding a collection, you need to iterate over the collection documents and output item details in /portfolio.html.


---
layout: page
title: Portfolio
---
<section>
  <div>
    <div>
      {% for item in site.portfolio %}
        <div>
          <a href="{{ item.link }}">
            <img src="{{ item.image_path }}" alt="{{ item.project_name }}">
            <div>
              <div>
                <div>
                  {{ item.category }}
                </div>
                <div>
                  {{ item.project_name }}
                </div>
              </div>
            </div>
          </a>
        </div>
      {% endfor %}
    </div>
  </div>
</section>

collection

4. Blogging

This section is the instruction on how to insert a blog to your website.

Step 1: Create a layout for the posts

First, you need to create /_layouts/post.htm and insert some basic HTML, which helps you to format the content.


---
layout: page
---
<section>
  <div>
    <div>
      {{ content }}
    </div>
  </div>
</section>

Step 2: Create the post

Next, create the first post /_posts/2016-06-01-first-post.md


---
layout: post
title: My First Post
---
You'll find this post in your `_posts` directory. Go ahead and edit it and re-build
the site to see your changes. You can rebuild the site in many different ways, but
the most common way is to run `jekyll serve`, which launches a web server and
auto-regenerates your site when a file is updated.

To add new posts, simply add a file in the `_posts` directory that follows the
convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter.
Take a look at the source for this post to get an idea about how it works.

Step 3: Create blog.html

In order to list all your post, create blog.html


---
layout: page
title: Blog
---
<section>
  <div>
    <div>
      <div>
        <ul>
           {% for post in site.posts %}
             <li>
               <a href="{{ post.url }}">{{ post.title }}</a>
               - {{ post.date | date: "%d %B %Y" }}
             </li>
           {% endfor %}
        </ul>
      </div>
    </div>
  </div>
</section>

Step 4: Add link to /blog.html {#step-4-add-link-to-/blog.html}

In the navigation on /_layouts/default.html, insert link to /blog.html and your work are done.

...
<li>
  <a href="/blog.html">Blog</a>
</li>
...

All the posts are listed on blog page.

post

To see the entire post, please click on a link.

entire post

Conclusion

Now that you know how to insert a layout, collection, and blog to a static site, we hope that you can easily manipulate those above steps and make your site significantly more maintainable with Jekyll. If you want to improve your site even further, here are some recommendations: improving the navigation, inserting an RSS feed, inserting search, andinserting an estimated read time to posts.

Share this post:
BFCM 2026Deals across Avada appsNov 27–30