Jekyll可以从文件夹URL中省略index.html吗?

时间:2016-01-18 20:44:43

标签: jekyll

Jekyll docs on creating pages包含这个包含index.html个文件的文件夹示例:

  

要使用Jekyll为页面创建干净的URL,您只需为所需的每个顶级页面创建一个文件夹,然后在每个页面的文件夹中放置一个index.html文件。这样,页面URL最终成为文件夹名称,Web服务器将提供相应的index.html文件。以下是此结构的示例:

.
├── _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/

请注意,示例中的网址只是文件夹名称 - 不是index.html

但是,当我在自己的Jekyll网站中使用此结构时,会出现如下模板:

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

...输出这样的HTML:

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

有人建议使用这样的前端问题来修复网址:

---
permalink: projects/
---

这为我提供了我想要的网址,但要求我为每个网页添加该网址。有没有办法让Jekyll自动从URL中省略index.html

1 个答案:

答案 0 :(得分:0)

这似乎与GekHub Pages使用的Jekyll 2.4.0有关,但在Jekyll 3中已修复。

相关问题