$ gem install jekyll bundler
Gemfile
to list your project's dependencies:$ bundle init
Writing new Gemfile to /path/to/jekyll/Gemfile
Gemfile
in a text editor and add jekyll as a dependency:gem "jekyll"
bundle
to install jekyll for your project.$ bundle
Bundle complete! 1 Gemfile dependency, 31 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$ bundle info jekyll
* jekyll (4.3.3)
Summary: A simple, blog aware, static site generator.
Homepage: https://jekyllrb.com
Source Code: https://github.com/jekyll/jekyll
Changelog: https://github.com/jekyll/jekyll/releases
Bug Tracker: https://github.com/jekyll/jekyll/issues
Path: /path/to/gems/gems/jekyll-4.3.3
bundle exec
to make sure you use the jekyll version defined in your Gemfile
.index.html
in your site root directory.jekyll new <PATH>
command.jekyll new myblog
creates a new Jekyll site at ./myblog
.jekyll build
- Builds the site and outputs a static site to a directory called _site
.jekyll serve
- Does jekyll build
and runs it on a local web server at http://localhost:4000, rebuilding the site any time you make a change.jekyll serve --livereload
.$ jekyll serve
Configuration file: none
Source: /path/to/jekyll/tutorial_site
Destination: /path/to/jekyll/tutorial_site/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 0.005 seconds.
Auto-regeneration: enabled for '/path/to/jekyll/tutorial_site'
Server address: http://127.0.0.1:4000
Server running... press ctrl-c to stop.
.
├── _config.yml
├── _data
│ └── members.yml
├── _drafts
│ ├── begin-with-the-crazy-ideas.md
│ └── on-simplicity-in-technology.md
├── _includes
│ ├── footer.html
│ └── header.html
├── _layouts
│ ├── default.html
│ └── post.html
├── _posts
│ ├── 2007-10-29-why-every-programmer-should-play-nethack.md
│ └── 2009-04-26-barcamp-boston-4-roundup.md
├── _sass
│ ├── _base.scss
│ └── _layout.scss
├── _site
├── .jekyll-cache
│ └── Jekyll
│ └── Cache
│ └── [...]
├── .jekyll-metadata
└── index.html # can also be an 'index.md' with valid front matter
{{
and }}
.{{ page.title }}
displays the page.title
variable.{%
and %}
.{% if page.show_sidebar %}
<div class="sidebar">
sidebar content
</div>
{% endif %}
show_sidebar
page variable is true.|
.{{ "hi" | capitalize }}
Hi
instead of hi
.Hello World!
text lowercase:...
<h1>{{ "Hello World!" | downcase }}</h1>
...
---
# front matter tells Jekyll to process Liquid
---
---
my_number: 5
---
page
variable.{{ page.my_number }}
.<title>
on your site to use front matter: tutorial_site/front_matter/index.html
(http://localhost:4000/front_matter/)_layouts
._layouts
directory in your site's root folder and create a new default.html
file.index.html
except:content
variable.content
is a special variable that returns the rendered content of the page on which it's called.layout
variable instead of page
.---
city: San Francisco
---
<p>{{ layout.city }}</p>
{{ content }}
index.html
use your new layout, set the layout
variable in the front matter.page
in the layout file.about.md
(http://localhost:4000/layouts/about.html) to use your new layout in the About page.
include
tag allows you to include content from another file stored in an _includes
folder._includes/navigation.html
.include
tag to add the navigation to _layouts/default_include.html
.tutorial_site/includes/index.html
and tutorial_site/includes/about.md
. (http://localhost:4000/includes/)_includes/navigation.html
needs to know the URL of the page it's inserted into so it can add styling.page.url
variable, you can check if each link is the current page and colour it red if true:<a href="/includes/" {% if page.url == "/includes/" %}style="color: red;"{% endif %}>
<a href="/includes/about.html" {% if page.url == "/includes/about.html" %}style="color: red;"{% endif %}>
_data
directory._data/navigation.yml
.site.data.navigation
._includes/navigation_data.html
, now you can iterate over the data file instead. (http://localhost:4000/data/).
├── assets
│ ├── css
│ ├── images
│ └── js
...
_includes/navigation_data.html
is not a best practice._includes/navigation_assets.html
.assets/css/styles.scss
.@import "main"
tells Sass to look for a file called main.scss
in the _sass
directory by default.current
class in order to colour the current link green at _sass/main.scss
._layouts/default_assets.html
) and add the stylesheet to the <head>
.styles.css
referenced here is generated by Jekyll from styles.scss
in assets/css/
._posts
._posts/2018-08-20-bananas.md
.author
is a custom variable; it's not required and could have been named something like creator
._layouts/post.html
.date_to_string
filter, which formats a date into a nicer format.site.posts
.blog.html
in your site root directory.post.url
is automatically set by Jekyll to the output path of the post.post.title
is pulled from the post filename and can be overridden by setting title
in front matter.post.excerpt
is the first paragraph of content by default._data/navigation_blogging.yml
for navigation._config.yml
(by default)._config.yml
in the site root directory.bundle exec jekyll serve
) to (re)load the configuration._*collection_name*
, in this case, _authors
.site.authors
.staff.html
and iterate over site.authors
to output all the staff.markdownify
filter.{{ content }}
in a layout._data/navigation_collections.yml
.output: true
to the author collection configuration: _config.yml
.author.url
in staff.html
._layouts/author.html
._config.yml
._layouts/post.html
.{% assign author = site.authors | where: 'short_name', page.author | first %}
:site.authors
collection to the author
variable;where
filter to create an array to include only objects where the short_name
property is the post page's page.author
custom variable value;first
filter to return the first item in the array.jekyll new <PATH>
command), Jekyll installs a site that uses a gem-based theme called Minima.assets
, _data
, _layouts
, _includes
, and _sass
directories) are stored in the theme's gem..
├── 404.html
├── about.markdown
├── _config.yml
├── Gemfile
├── index.markdown
└── _posts
└── 2024-05-07-welcome-to-jekyll.markdown
bundle update
to update all gems in your project.update <THEME>
, replacing <THEME>
with the theme name, such as minima
, to just update the theme gem._layouts
or _includes
directory.page
layout, you can override it by creating your own _layouts/page.html
._sass/minima.scss
in the Minima theme) into the _sass
directory in your site's source.bundle info --path <THEME>
, e.g., bundle info --path minima
.$ bundle info --path minima
/path/to/gems/minima-2.5.1
$ tree $(bundle info --path minima)
/path/to/gems/minima-2.5.1
├── assets
│ ├── main.scss
│ └── minima-social-icons.svg
├── _includes
│ ├── disqus_comments.html
│ ├── footer.html
│ ├── google-analytics.html
│ ├── header.html
│ ├── head.html
│ ├── icon-github.html
│ ├── icon-github.svg
│ ├── icon-twitter.html
│ ├── icon-twitter.svg
│ └── social.html
├── _layouts
│ ├── default.html
│ ├── home.html
│ ├── page.html
│ └── post.html
├── LICENSE.txt
├── README.md
└── _sass
├── minima
│ ├── _base.scss
│ ├── _layout.scss
│ └── _syntax-highlighting.scss
└── minima.scss
5 directories, 22 files
jekyll new <PATH>
command isn't the only way to create a new Jekyll site with a gem-based theme.Gemfile
, or if you've started with the jekyll new
command, replace gem "minima", "~> 2.0"
with the gem you want:gem "jekyll-theme-minimal"
bundle install
_config.yml
to activate the theme:theme: jekyll-theme-minimal
bundle exec jekyll serve