Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm building a website in Jekyll. To remove html extension in posts I added the following to _config.yml

permalink:        /kb/:title

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

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

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

like image 256
jupiteror Avatar asked Feb 26 '14 07:02

jupiteror


1 Answers

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

To get the urls to not include the "index.html" part you will need to add a permalink setting to the front matter for each of these pages. This actually removes the need of having all the files named "index.html" and in separate folders.

So your front matter would contain something like:

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

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

like image 180
David Hutchison Avatar answered Sep 18 '22 09:09

David Hutchison