Exploring Jekyll Basics via a Blog

Topics: YAML; config.yml; front matter; index.md; posts

In this section we set up a Jekyll blog on GitHub Pages to learn about _config.yml, YML front matter, and Posts.


Set Up Your Project Repository

First, create a new repository for your example blog:

Second, activate GitHub Pages:


Configure Site

The first step to starting a Jekyll project is to create _config.yml, which will contain site wide configuration options, variables, and settings. For example, config values such as title will be used to populate template elements throughout your final web site.

YAML is a plain text data format (using extension .yml) designed to be fairly easy to write and read, yet still provide advanced data structures similar to XML or JSON. It is used in Jekyll for configuration, page front matter, and site data. Most options will be key-value pairs, looking something like:

example_key: example value

Create _config.yml

# Site settings
title: Great New Blog Title
author:
  name: Evan Will
  email: your-email@domain.com
description: "Great site about Jekyll on GH-Pages."

# Build settings
remote_theme: jekyll/minima

A few notes about the YAML in the example above:


Home Page

With the basics of our site set in _config.yml, next we will need a home page.

For every page in the site, we need to create a content stub in Markdown or HTML with YAML Front Matter. During build, Jekyll will process all files with YAML front matter (even if its empty), rendering the Markdown and wrapping the content in the theme to generate the final HTML page. Any files without front matter will be copied to the site without processing.

YAML front matter is denoted by three dashes on a line (---), followed by some YAML (optional), and closed by three more dashes on a line. For example:

---
# a comment 
example_key: example value
---

The YAML front matter will not appear as part of the content, unless it is pulled in by the theme. For example, themes often set the page’s header based on the title value given in the front matter. It is often necessary to set a layout to use custom templates for different types of pages.

Create index.md

---
layout: home 
---

Welcome to my new blog!

With this commit the new blog should be live! Look for the green check next to your commit history, then surf to the URL following the pattern:

https://username.github.io/repositoryname/


Write Posts

Blogs are made up of Posts… and Jekyll has the concept built in to its default structure. Markdown stubs created in the _posts folder will flesh out your content and can be accessed in layouts by date, tag, and category.

Each post must be given a filename following the pattern:

yyyy-mm-dd-title.md

For example, “2020-10-31-happy-halloween.md” or “1990-01-01-first-day-of-www.md”.

Create _posts

---
layout: post
title: My First Jekyll Post
tags: first markdown example
categories: demo
---

This is a paragraph in my first post.
Show off your Markdown!

## Heading Two 

Any text with no empty lines between will become a paragraph.
Leave an blank line between headings and paragraphs.
Font can be *Italic* or **Bold**.
Code can be highlighted with `backticks`.

Hyperlinks look like this [GitHub Help](https://help.github.com/).

A bullet list is created using `*`, `+`, or `-`, like:

- dog
- cat
- muffin

A numbered list is created using a number + `.`, like:

1. one
2. two
6. three
2. four

Keep Posting, More Markdown

---
layout: post
title: Next Steps
tags: second markdown example
categories: demo
---

This is a paragraph in my second post.
In Markdown, adding an image looks similar to a link. 

![alt text is white cat](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/VAN_CAT.png/480px-VAN_CAT.png)

I found this [Cat image on Wikimedia](https://commons.wikimedia.org/wiki/File:VAN_CAT.png).

Horizontal rule:

--------------

> A block quote.
> Is like this.

A table:

| header | column a | column b |
| --- | --- | --- |
| dogs | 3 | 6 |
| cats | 3 | 6 |
| muffins | 15 | 30 |


Posts, Collections, & Pages

Of course not every website is a blog. The _posts directory is completely optional. Posts are optimized to simplify writing blog-like content with features like date, title, and categories built into the filename convention.

Collections provide another flexible option for creating groups of content that can be sorted and iterated over using built in methods (Posts are in fact a specialized, built in Collection).

However, many sites will use only Pages for content.

We have already created index.md, so let’s create the other essential, an About page.

Create about.md

---
layout: page
title: About
---

Some Markdown content describing your site.

## About About Pages

The About page is a common convention found on websites.
It is your opportunity to let us know all the details "about" your project:

- focus and topic area
- people involved
- code and projects used

Be sure to check out what your blog looks like with all this new content!