Jekyll - How to create pages in the root directory?

I am using Jekyll to create a page and the docs suggest that Jekyll should be able to create pages in the root directory or create new directories for new pages.

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

The placement of HTML files for pages depends on how you want to use the pages to work. There are two main ways to create pages:

  • Place the HTML files for each page in the root folder of your sites.
  • Create a folder at the site root for each page and place an index.html 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?

+1


source to share


2 answers


If you create a page about.html

at the root of your Jekyll folder, it will be generated in _site/about.html

, except when you put a permalink in the front.

By default, there is a permalink about the page ( permalink: /about/

), which is then generated in _site/about/index.html

.

With a permalink, you can even do:



  • page pages/mypage.html

  • permalink: my-nice-page.html

  • generated in _site/my-nice-page.html

Note. If you set global permalink

to _config.yml

on pretty

, all pages will be generated in order to give a pretty url like http: //domain.tld/about/ (in _site/about/index.html

). You can change this variable to date or another, or put a permalink on your page to override the global one.

+6


source


You place them in any folder of your jekyll project. So if you are in a folder myjekyllproject

you will add a file called index.html or about.html. From there you will do jekyll build

. Jekyll will then include this file in your myjekyllproject/_site folder

.



+1


source







All Articles