Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 there a better what to achieve this results?

like image 664
Shawn Chin Avatar asked Jun 24 '11 13:06

Shawn Chin


3 Answers

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.

like image 181
josé camou Avatar answered Nov 10 '22 05:11

josé camou


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
like image 20
kenotron Avatar answered Nov 10 '22 04:11

kenotron


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.

like image 1
kikito Avatar answered Nov 10 '22 03:11

kikito