Jekyll分页博客作为子目录 [英] Jekyll paginate blog as subdirectory

查看:55
本文介绍了Jekyll分页博客作为子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将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:

paginate_path:/blog/page/:num

paginate_path: /blog/page/:num

在_config.yml中.

in _config.yml.

但是生成的结果页面位于:

But the resulting generated pages at:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆