开发者

Configuring per-directory permalink settings in jekyll

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 开发者_JAVA技巧there a better what to achieve this results?


Not sure if this will be any help now but I ran into the same problem trying to make a blog/portfolio and wanting to have /articles/2013/.. and /work/2013/..

What I did is just change the permalink to:

permalink: /:categories/:year/:title

and added 'articles' as a category for my blog posts and 'work' as a category for my work and it worked fine.


Just got inspired by jose's comment. Why not do this:

permalink: /:categories/:title

and then in the front matter for your blog just do

categories: blog 2013 05 01

for news only do

categories: news 2013


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜