Data files in the same directory as my source files?


I want to keep page-specific datafiles next to the source files which are going to use them, for clarity. So I want to end up with something like this:




Then I’ll have a custom tag in the markdown file actually use the yaml file to generate text.

Is there any way to achieve this?


not that I know of, data files go in the _data folder.


Just remember that the whole philosophy of Jekyll is to have conventions to avoid configuration. So most of the time, you don’t have configuration options for that kind of things.

FWIW you can change the default data folder but it’s a global setting, there’s no per page settings.

data_dir:        _pages/my-page/


The trouble with ‘convention over configuration’ is that it completely falls down when faced with, e.g., the kind of external requirements I have here. I really can’t rearrange the source files.

I think I can work around this by creating a _data.yaml file, so that it’s ignored by the generator, and then manually loading it in Ruby code. It’s really ugly, but it at least lets me make progress.


What prevents you from having a script moving the yaml files in the _data folder?


Nothing, of course, but it seems like a waste to add a whole other moving part for something which should be so simple…


If the data file is small, you could put it in the front matter.


@davidgiven I too see a need for data file next the the source files.

  1. All the source file in that same folder can make use of just one datafile, without front matter on each of the source file.
  2. Individual source file that need to overide the data can have individual front matter.

Will be perfect if the datafile can also be inherited from top-level folder(s)