diff --git a/site/_includes/docs_contents.html b/site/_includes/docs_contents.html index 0df6c0a4..523b5227 100644 --- a/site/_includes/docs_contents.html +++ b/site/_includes/docs_contents.html @@ -3,7 +3,7 @@

Getting Started

{% include docs_ul.html items='home quickstart installation usage structure configuration' %}

Your Content

- {% include docs_ul.html items='frontmatter posts drafts pages variables migrations' %} + {% include docs_ul.html items='frontmatter posts drafts pages variables datafiles migrations' %}

Customization

{% include docs_ul.html items='templates permalinks pagination plugins extras' %}

Deployment

diff --git a/site/_includes/docs_contents_mobile.html b/site/_includes/docs_contents_mobile.html index fe2a09ef..bbc367d4 100644 --- a/site/_includes/docs_contents_mobile.html +++ b/site/_includes/docs_contents_mobile.html @@ -5,7 +5,7 @@ {% include docs_option.html items='home quickstart installation usage structure configuration' %} - {% include docs_option.html items='frontmatter posts drafts pages variables migrations' %} + {% include docs_option.html items='frontmatter posts drafts pages variables datafiles migrations' %} {% include docs_option.html items='templates permalinks pagination plugins extras' %} diff --git a/site/docs/datafiles.md b/site/docs/datafiles.md new file mode 100644 index 00000000..c4e9e7e9 --- /dev/null +++ b/site/docs/datafiles.md @@ -0,0 +1,63 @@ +--- +layout: docs +title: Data Files +prev_section: variables +next_section: migrations +permalink: /docs/datafiles/ +--- + +In addition to the [built-in variables](../variables/) available from Jekyll, +you can specify your own custom data that can be accessed via the [Liquid +templating system](http://wiki.github.com/shopify/liquid/liquid-for-designers). + +Jekyll supports loading data from [YAML](http://yaml.org/) files located in the +`_data` directory. + +This powerful features allows you to avoid repetition in your templates and to +set site specific options without changing `_config.yml`. + +Plugins/themes can also leverage Data Files to set configuration variables. + +## The Data Folder + +As explained on the [directory structure](../structure/) page, the `_data` +folder is where you can store additional data for Jekyll to use when generating +your site. These files must be YAML files (using either the `.yml` or `.yaml` +extension) and they will be accessible via `site.data`. + +## Example: List of members + +Here is a basic example of using Data Files to avoid copy-pasting large chunks of +code in your Jekyll templates: + +In `_data/members.yml`: + +{% highlight yaml %} +- name: Tom Preston-Werner + github: mojombo + +- name: Parker Moore + github: parkr + +- name: Liu Fengyun + github: liufengyun +{% endhighlight %} + +This data can be accessed via `site.data.members` (notice that the filename +determines the variable name). + +You can now render the list of members in a template: + +{% highlight html %} +{% raw %} + +{% endraw %} +{% endhighlight %} diff --git a/site/docs/migrations.md b/site/docs/migrations.md index b1890abb..431e2a8b 100644 --- a/site/docs/migrations.md +++ b/site/docs/migrations.md @@ -1,7 +1,7 @@ --- layout: docs title: Blog migrations -prev_section: variables +prev_section: datafiles next_section: templates permalink: /docs/migrations/ --- diff --git a/site/docs/variables.md b/site/docs/variables.md index 3f172f20..89e11a52 100644 --- a/site/docs/variables.md +++ b/site/docs/variables.md @@ -2,7 +2,7 @@ layout: docs title: Variables prev_section: pages -next_section: migrations +next_section: datafiles permalink: /docs/variables/ ---