Jekyll won't parse frontmatter from outside the source directory
skroll opened this issue · comments
Not sure if this is a recent change (I just started poking around the new octopress recently), but Jekyll refuses to load yaml frontmatter from anything outside the site source directory. So if a layout exists in a plugin, it won't be processed (and throws an error) such as:
Error reading file /home/skroll/src/theme-test/assets/layouts/post.html: No such file or directory @ rb_sysopen - /home/skroll/src/octopress-site-test/home/skroll/src/theme-test/assets/layouts/post.html
You can see how it just appended the absolute path to the end of the site's path. Currently it seems Jekyll's layouts use Jekyll::Site#in_source_dir
to generate the path sent to the yaml parser, which in turn ensures that a path exists within the site path, and won't take absolute paths.
Would you mind telling me which plugin you're using and how you're referencing the layout?
As a test I made a simple plugin taking the layouts/stylesheets from the default jekyll theme. I put it up here: https://github.com/skroll/octopress-theme-jekyll-default
There's nothing much to it, the slug gets set as 'theme', so in my page in my site I'm referencing it with:
layout: theme:default
But looking at the Jekyll code I don't see how it could work because when the path is passed on to Jekyll, the in_source_dir method on Jekyll:Site will never allow for absolute paths when processing.
I downloaded the octopress-theme-jekyll-default
git project and tried out the demo. It worked but I had to make small changes.
1. Instead of assets/config.yml
The site you're testing with needs to have the gem list in the _config.yml
. For example, to get it to work with the demo, you need in demo/_config.yml
:
gems:
- octopress-theme-jekyll-default
2. With that, add this to the index.html
---
layout: theme:page
---
And the Jekyll build will work just fine.