jekyll settings

2023-10-16 hit count image

We introduce basic jekyll settings. This post is for how to set _config.yml file and how to use variables in jekyll.

jekyll settings

jekyll is very flexible system and has many configuration options for making a website. 설정은_config.yml` We focus on the options we use in here.

Variables

Before we talk about settings, we quickly talk about basic jekyll variables for understanding the configurations. If you want to know more detail, please see jekyll homepage(variables)

Global variables

  • site: this is about site informations. This variable includes informations set on _config.yml and basic informations provided by jekyll.
  • page: this variable is about current page informations. This has informations written in yml format at the top of the page file.
  • content: this is used on layout files in _layout folder. This contains contents written on the page.

site variable

You can declare variables in _config.yml and use it with site.[variable name]. Almost plugins use _config.yml to set the necessary variables. We introduce about site global variables we mainly use.

  • site.time: this is a time variable when jekyll command is executed. we use it for sitemap.xml modification time, and css version on header tag for disabling cache.
  • site.pages: this variable includes all pages except pages in _posts folder. we use it for writing all static pages on sitemap.xml except post pages, and category pages on the bottom of the Top page.
  • site.posts: this is all pages in _posts folder.
  • site.url: this is a site URL. this is used by configuring real site url(https://dev-yakuza.github.io). If you test the jekyll site by executing bundle exec jekyll serve command, jekyll ignore this url and automatically set http://localhost:4000. When you execute bundle exec jekyll build command for deploying the site, jekyll use this url.

page variable

Here are page’s global variables which are on the top of the page with yml format.

  • page.title: this is a page title. we use it on <title> tag in <head> tag, title on the top of the post and display post list on category page.
  • page.url: this is the page url. we use it for everywhere that required the link like sitemap.xml.
  • page.date: the date assigned to the post.
  • page.categories: the category list that is belonged the post.

jekyll basic configuration

Default settings file

  • here are options on _config.yml files.
title: ...
email: '[email protected]'
description: ...
baseurl: ...
url: https://dev-yakuza.github.io
twitter_username: ...
github_username: ...
author: [email protected]

markdown: kramdown
plugins:
  - jekyll-feed
  - jekyll-paginate-v2
  - jekyll-polyglot
  - jekyll-seo-tag

exclude:
  - Gemfile
  - Gemfile.lock

# pagination
permalink: /:year/:month/
pagination:
  enabled: true
  per_page: 12
  sort_reverse: true
  limit: 0
  sort_field: 'date'
  permalink: '/page/:num/'
  title: ':title'
  trail:
    before: 2
    after: 2

# multilang
languages: ['ja', 'ko', 'en']
default_lang: 'ja'
exclude_from_localization: ['javascript', 'images', 'css']
parallel_localization: false

Default settings

  • title: this is the title of the site. basically, this is used on <title> tag in <head> tag, but we don’t use it because we use titie variable on page options.
  • email: this is a option for setting email. We use it for sending email to us on Contact. If you want to know how to send email on jekyll, please ses Send email.
  • description: just like title, this will be on the page head tag. However, we use page description instead of this option.
  • url: this is a site URL. this is used by configuring real site url(https://dev-yakuza.github.io). If you test the jekyll site by executing bundle exec jekyll serve command, jekyll ignore this url and automatically set http://localhost:4000. When you execute bundle exec jekyll build command for deploying the site, jekyll use this url.
  • author: the author of the site. use it on author meta tag in head tag.
  • plugins: set plugins used on the site.

Configuration for plugins

see each plugin posts about each plugin option details.

Pagination plugin configuration
permalink: /:year/:month/
pagination:
  enabled: true
  per_page: 12
  sort_reverse: true
  sort_field: 'date'
  title: ':title'
  trail:
    before: 2
    after: 2
Multi-languages plugin configuration
languages: ['ja', 'ko', 'en']
default_lang: 'ja'
exclude_from_localization: ['javascript', 'images', 'css']
parallel_localization: false

Page setting options

  • this options are the top of the blog post files in _posts.
layout: 'post'
permalink: '/jekyll/configuration/'
paginate_path: '/jekyll/:num/configuration/'
lang: ...
categories: 'jekyll'
comments: true

title: ...
description: ...
image: '/assets/images/category/jekyll/configuration.jpg'
  • layout: set the layout which page use.
  • title: set the page title.
  • description: set the page description.

Plugin setting options in Page settings

We use these for plugins or managing the site. More details are on each blog posts.

  • paginate_path: Pagination plugin option. Determine Pagination URL.
  • lang: Multi-languages plugin options. this is what current page language is.
  • comments: the option for using Disqus comment service.
  • description: show description with title on the top of the page and head’s description.
  • image: post hero image. it’s a background image on the top and og:image in head.

Reference

Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!

App promotion

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.

Posts