Where to find default layouts in Jekyll
Asked Answered
B

2

6

The default site setup for a new Jekyll site has a layout specified as "home" in index.md:

---
# You don't need to edit this file, it's empty on purpose.
# Edit theme's home layout instead if you wanna make some changes
# See: https://jekyllrb.com/docs/themes/#overriding-theme-defaults
layout: home
---

If I follow the link, it tells me to create a _layouts folder and create a file in it named home.html and that will be used as the home layout. But if that file doesn't exist Jekyll defaults back to the normal home page.

Where is Jekyll pulling the default layout from?

Borer answered 8/10, 2018 at 20:47 Comment(0)
B
7

This default layout comes from the theme, which is gem based and is stored on your computer.

To locate a theme’s files on your computer:

Run bundle show followed by the name of the theme’s gem, e.g., bundle show minima for Jekyll’s default theme. This returns the location of the gem-based theme files. For example, the Minima theme’s files might be located in /usr/local/lib/ruby/gems/2.3.0/gems/minima-2.1.0 on macOS.

Source

I would suggest to start without a theme. Invisible files do not really help you to understand an already quite abstract concept. Remove the theme and write your own layouts and CSS. When you get how it works, you also truly understand how a theme works and what it can and cannot do.

Removing the standard (or any other) theme is simple. Just go to the _config.yml file and remove theme: minima. Now you will use only visible files. You might also want to remove the 'Gemfile', but that requires you to also remove the 'jekyll-feed' plugin from the config. No problem, as you can easily roll your own: https://jekyllcodex.org/without-plugin/rss-feed/

Bradford answered 8/10, 2018 at 22:41 Comment(2)
Does running jekyll new install minima by default?Borer
Yes it does... unfortunately.Bradford
D
4

From this version of the manual:

Run bundle info --path followed by the name of the theme's gem, e.g., bundle info --path minima for Jekyll's default theme.

The layout files will be in the _layouts sub-directory of the path returned by the command above.

Diorama answered 6/1, 2022 at 9:33 Comment(1)
The manual has changed since the original question and the previous answer. Thus I am posting this updated answer for others to quickly find a newer solution. Be aware, that the manual may change again.Diorama

© 2022 - 2024 — McMap. All rights reserved.