Masatoshi Nishiguchi

Jekyll notes

This is my notes on what I learned about Jekyll through my own blog site.

page.url

Setting up Disqus

Canonical URLs with Jekyll

<link rel="canonical" href="https://mnishiguchi.com/2017/12/03/jekyll-notes/">
<link rel="stylesheet" href="/styles.css">

Pagination

Post excerpts

1. Specify a separator for experpts in _config.yml

excerpt_separator:  

2. Insert the excerpt separator in a post.

---
layout: post
title: My first blog
comments: true
tags: general
---

Hi, this is Masatoshi Nishiguchi. I am writing a blog post for the first time.

The primary purpose of this is for me to learn how blog works at the moment. That's it. But I might eventually find out some other purposes that are more fun and more useful for the Internet communities.

 

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

3. Access the experpt of a post in a template

{{ post.excerpt }}

Sitemaps for GitHub Pages

jekyll-sitemap plugin

plugins:
  - jekyll-sitemap

Markdown in yaml

Single paragraphs (>)

# Markdown enabled, however don't use more than one paragraph (enforced by `>`)
description: >
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Multiple paragraphs (|)

# Markdown enabled, can use multiple paragraphs (enabled by `|`)
about: |
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Creating local variables using variable tags

{% assign my_variable = false %}

{% if my_variable != true %}
This statement is valid.
{% endif %}

Detecting page or posts

<div class="{{ if page.id }} post {{ else }} page {{ endif }}">
   ...
</div>

Creating an array with Jekyll

<!--Create an emply array-->
{% assign tag_names = "" | split: "|" %}

<!--Obtain a tag name and push it to the array-->
{% for posts_by_tag in site.tags %}
  {% assign tag_names = tag_names | push: posts_by_tag.first %}
{% endfor %}

<!--Sort the tag names-->
{% assign tag_names = tag_names | sort %}

Outputting curly braces or Liquid tags in Jekyll templete

A: Use raw tag

B: Create custom variables

CSS themes for Pygments syntax highlighter