在jekyll中配置每个目录的固定链接设置 [英] Configuring per-directory permalink settings in jekyll

查看:888
本文介绍了在jekyll中配置每个目录的固定链接设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以为不同的目录设置不同的固定链接吗?



例如,如果我有一个Jekyll设置,博客条目写入 / blog / _posts / / news / _posts 中的新闻条目,则默认情况下每个条目将以 /blog/2011/06/24/slug.html /news/2011/06/24/slug.html

博客条目的固定链接很好,但是我需要将新闻的固定链接格式更改为不同的格式,例如 / news / 2011 / slug



我尝试更改YAML前端的 permalink 对于新闻项目使用的布局,但这不起作用,因为YAML前端内容中的固定链接设置没有内插(在答案中确认)



是否有一种机制来配置 _config.yaml 中的路径特定设置, ?

解决方案

你可以实现的唯一方法是通过两个不同的jekyll实例



您可以拥有(例如)拥有网页和博客的完整网站,以及新闻文件夹中的微型网站,并且拥有自己的'_config.yaml' 。 top必须完全忽略新闻目录,并且必须将新闻目录配置为在../_ site / news内生成其输出。



最大的障碍是,你不能运行Jekyll作为服务器;你必须使用脚本(即Rakefile)为jekylls生成静态页面,并用不同的服务器(例如独角兽)来提供它们。



说,这将是一个障碍,但在1小时或更少的时间。


Is it possible to have different permalink settings for different directories?

For example, if I have a Jekyll setup where blog entries are written into /blog/_posts/ and news items in /news/_posts, then by default each entry will have permalinks in the format /blog/2011/06/24/slug.html and /news/2011/06/24/slug.html.

The permalinks for blog entries are fine as they are, but I need to change the permalinks format for news to something different, say /news/2011/slug.

I've tried changing the permalink settings in the YAML front matter for the layout used by news item, however, this does not work since permalink settings in YAML front matter are not interpolated (as confirmed in the answer to this question).

Is there a mechanism to configure path specific settings in _config.yaml? Or is there a better what to achieve this results?

解决方案

The only way you can achieve that is by having two different jekyll instances.

You could have (for example) a full site with the pages and blogs, and a "microsite" inside the news folder, with it's own ´_config.yaml´ . The "top" would have to ignore the news directory completely, and the news directory would have to be configured to generate its output inside "../_site/news".

The biggest hurdle would be that you would not be able to run Jekyll as a server; you would have to use a script (i.e. a Rakefile) to generate the static pages for both jekylls, and serve them with a different server (i.e. unicorn).

Like I said, it'd be a bit of a hurdle, but doable in 1h or less.

这篇关于在jekyll中配置每个目录的固定链接设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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