Jekyll 将博客分页为子目录 [英] Jekyll paginate blog as subdirectory
问题描述
我将 Jekyll 用于静态站点,并尝试将博客生成为子目录/子文件夹:
I'm using Jekyll for a static site and I'm trying to generate the blog as a subdirectory/subfolder:
http://example.com/blog
在运行jekyll之前的目录结构中,这是blog/index.html.
In the directory structure before running jekyll, this is blog/index.html.
我尝试通过在 _config.yml 中添加paginate: 5"来添加分页,但生成的 url 格式如下:
I tried adding pagination by adding "paginate: 5" to _config.yml, but the generated url's were of the form:
http://example.com/page2/
即没有/博客".这是通过以下方式修复的:
i.e. no "/blog". This is fixed by:
分页路径:/blog/page/:num
paginate_path: /blog/page/:num
在 _config.yml 中.
in _config.yml.
但是生成的页面在:
http://example.com/blog/page/2/
不要使用 blog/index.html 作为他们的布局.他们使用根 index.html.那么,即使有 paginate_path 选项又有什么意义呢?
don't use blog/index.html as their layout. They use the root index.html. What's the point in even having the paginate_path option, then?
如何使用 Jekyll 在 example.com/blog 上获取我的博客,并使用分页?
How do I get my blog at example.com/blog, with pagination, using Jekyll?
推荐答案
使用 _config.yml 文件中的 destination
键来设置要将输出发布到的基本路径.例如,
Use the destination
key in your _config.yml file to set the base path where you want the output to be published to. For example,
paginate: 5
destination: _site/blog
请注意,假设您的站点设置为其根服务器(例如http://example.com/") 来自_site" jekyll 不会在该位置生成index.html"页面.jekyll 构建的所有内容都将位于blog"目录下,但这听起来像是您所追求的.
Note that assuming your site is setup to server its root (e.g. "http://example.com/") from "_site" jekyll won't produce and "index.html" page at that location. Everything that jekyll builds will be under the "blog" directory, but that sounds like what you are after.
这篇关于Jekyll 将博客分页为子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!