How to link to page with page.url without html extension in Jekyll?

I am building a site in Jekyll. To remove the html extension in posts, I added the following to _config.yml

permalink: /kb/:title 

To remove the html extension from pages, I created folders for each page and placed the index.html file in each folder.

Now posts and pages work without the html extension, but when I link to a page with page.url, it returns the whole link (/kb/index.html) instead of just / kb.

Which variable can I use to link to a page without the html extension?

+8
ruby jekyll liquid
source share
1 answer

The value returned by {{ page.url }} reflects what is specified for the page.

In order to get the URLs, so as not to include the β€œindex.html” part, you will need to add the front link constant parameter for each of these pages. This virtually eliminates the need for all files named "index.html" in separate folders.

So your front question will contain something like:

 --- permalink: /scratchpad/level/relative/ --- 

Note the trailing slash, if you omit this, Jekyll will create a file called "relative" instead of the directory containing the index.html file.

+7
source share

All Articles