Aaron Benjamin
Aaron Benjamin

Reputation: 1389

Jekyll - How do I create pages in the root directory?

I'm using Jekyll to create a page and the docs suggest that Jekyll has the option to create pages in the root directory, or to create new directories for new pages.

From http://jekyllrb.com/docs/pages/

Where you put HTML files for pages depends on how you want the pages to work. There are two main ways of creating pages:

  • Place named HTML files for each page in your site’s root folder.
  • Create a folder in the site’s root for each page, and place an index.html file in each page folder.
project
-- _includes
-- _site
---- about
------ index.html
----assets
------ css
------ img
------ js
--assets
---- css
---- img
---- js
-- _config.yml
-- about.html
-- index.html

How do I configure Jekyll to create pages in the root directory?

Upvotes: 2

Views: 4627

Answers (2)

David Jacquel
David Jacquel

Reputation: 52789

If you create an about.html page at the root of you Jekyll folder, it will generated in _site/about.html except if you put a permalink in the front matter.

By default the about page has a permalink (permalink: /about/) it is then generated in _site/about/index.html.

With permalink you can even do :

  • page in pages/mypage.html
  • permalink: my-nice-page.html
  • generated at _site/my-nice-page.html

Note: If you set your global permalink in _config.yml to pretty, all pages will be generated in order to give pretty urls like http://domain.tld/about/ (in _site/about/index.html). You can the change this variable to date or other or put a permalink in your page to override the global one.

Upvotes: 6

Marc K
Marc K

Reputation: 271

You place them in whatever your jekyll project folder is. So if you're folder is myjekyllproject then you'll add a file named index.html or about.html. From there you will do a jekyll build. Jekyll will then put include that file in your myjekyllproject/_site folder.

Upvotes: 1

Related Questions