How to make a Jekyll _pages directory

March 2018

Jekyll is such a clean, lightweight site generator, but it can be hard to keep your project organized if your site uses a lot of pages. Luckily, you can use this Github-Pages-friendly method to create a dedicated _pages directory inside your project, keeping your root directory clear of disorganized bloat. It’s very simple to add this functionality:

  1. In your Jekyll project’s _config.yml, add this line:
    include: ['_pages']
  2. Then, create a directory called _pages at the top level of your project.

  3. Add pages to the _pages directory. And give them frontmatter, like this:
    title:     My Awesome Page
    permalink: /awesome
    layout:    page
  4. Frontmatter is very important! The permalink field must be defined for every page in the _pages directory, otherwise you’ll receive a 404. You may also need to change the layout property to match your desired layout.