【发布时间】:2019-11-04 01:27:07
【问题描述】:
如何更改默认起始页?目前,index.html 始终是帖子的索引。
我喜欢在 index.html 上显示我当前 /about 页面的内容,并且喜欢有一个指向帖子索引的 /articles 链接。
将/about/index.html 的内容复制粘贴到/index.html 中是唯一的解决方案吗?
【问题讨论】:
标签: jekyll
如何更改默认起始页?目前,index.html 始终是帖子的索引。
我喜欢在 index.html 上显示我当前 /about 页面的内容,并且喜欢有一个指向帖子索引的 /articles 链接。
将/about/index.html 的内容复制粘贴到/index.html 中是唯一的解决方案吗?
【问题讨论】:
标签: jekyll
这不是一个真正的 Jekyll 问题,它更像是一个信息架构问题。
您的页面层次结构是这样的:
|-index.html
|-articles.html
|-...
如果你想在markdown中写,只需在index.html或index.md中添加你想要的内容。
创建一个article.html 或md 页面并将index.html 的实际内容复制到其中。
最后,如果您想通过/articles/ 访问您的文章页面,只需在前面添加permalink: articles/。否则,默认情况下将通过articles.html 到达。
【讨论】:
您可以使用jekyll中的gem 'jekyll-redirect-from'设置与index.html不同的主页,也可以自定义任意xxxx.html的输出URL。
将此行添加到您项目的Gemfile:
gem 'jekyll-redirect-from'
然后在终端执行:
bundle
一旦安装到您的环境中,请将其添加到您的_config.yml:
plugins:
- jekyll-redirect-from
现在,将about.html 设置为主页:
在about.html开头添加:
---
permalink: /
redirect_from:
- /about
---
因此,www.website.com/about 将重定向到 www.website.com 并显示 about.html 的内容。
【讨论】: