s4y
s4y

Reputation: 51765

Can Jekyll omit index.html from folder URLs?

The Jekyll docs on creating pages include this example of folders containing index.html files:

To achieve clean URLs for pages using Jekyll, you simply need to create a folder for each top-level page you want, and then place an index.html file in each page’s folder. This way the page URL ends up being the folder name, and the web server will serve up the respective index.html file. Here’s an example of what this structure might look like:

.
├── _config.yml
├── _includes/
├── _layouts/
├── _posts/
├── _site/
├── about/
|   └── index.html  # => http://example.com/about/
├── contact/
|   └── index.html  # => http://example.com/contact/
|── other/
|   └── index.md    # => http://example.com/other/
└── index.html      # => http://example.com/

Note that the URLs in the example are just the folder names — no index.html.

When I use this structure in my own Jekyll site, though, a template like this:

{% for page in site.pages %}{% if page.title %}
    <a href="{{ page.url }}">{{ page.title }}</a>
{% endif %}{% endfor %}

…outputs HTML like this:

<a href="/projects/index.html">Projects</a>
<a href="/blog/index.html">Blog</a>

Someone suggested using front matter like this to fix the URLs:

---
permalink: projects/
---

This gives me the URLs I want but requires that I add that for each page. Is there a way to get Jekyll to omit index.html from the URL automatically?

Upvotes: 1

Views: 311

Answers (1)

s4y
s4y

Reputation: 51765

This appears to be an issue with Jekyll 2.4.0, which GitHub Pages uses, but is fixed in Jekyll 3.

Upvotes: 0

Related Questions