Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Creating a layout

Gautam edited this page Apr 26, 2016 · 8 revisions
  • Create a file under _layouts
  • Give it a descriptive name, (don't use names like template, mytemplate and so on) be sure the name doesn't contain spaces, - or other special characters. Using lowercase with underscores to separate words is recommended. Eg useful_template_name.html
  • A layout consists of two parts, the HTML which defines the structure of the page and the content which is written for each post / unit.
  • Here's a simple layout
<!DOCTYPE html>
<html>
<head>
    <title>{{ site.title }}</title>
</head>
<body>
    <h1>This is using a sample layout</h1>
    <h2>The content created on {{ site.time | date_to_string }} goes below</h2>
    <div class="content">
        {{ content }}
    </div>
</body>
</html>
  • Notice the special markup enclosed in {{ }} which embeds a dynamic variable into the generated page.

  • For example {{ site.title }} embeds the title given by the author of the page in front matter

  • {{ content }} is the most important part of this template. It embeds the content written in markdown, html or any other markup language into the template to generate the final web page.

  • Read more about the various variable available for use at https://jekyllrb.com/docs/variables/

Clone this wiki locally