site/docs/datafiles/index.html in jekyll-docs-3.2.1 vs site/docs/datafiles/index.html in jekyll-docs-3.3.0

- old
+ new

@@ -2,11 +2,11 @@ <html lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> - <meta name="generator" content="Jekyll v3.2.1"> + <meta name="generator" content="Jekyll v3.3.0"> <link type="application/atom+xml" rel="alternate" href="https://jekyllrb.com/feed.xml" title="Jekyll • Simple, blog-aware, static sites"> <link rel="alternate" type="application/atom+xml" title="Recent commits to Jekyll’s master branch" href="https://github.com/jekyll/jekyll/commits/master.atom"> <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic,900"> <link rel="stylesheet" href="/css/screen.css"> <link rel="icon" type="image/x-icon" href="/favicon.ico"> @@ -17,22 +17,22 @@ <meta property="og:description" content="In addition to the built-in variables available from Jekyll,you can specify your own custom data that can be accessed via the Liquidtemplating system."> <link rel="canonical" href="https://jekyllrb.com/docs/datafiles/"> <meta property="og:url" content="https://jekyllrb.com/docs/datafiles/"> <meta property="og:site_name" content="Jekyll • Simple, blog-aware, static sites"> <meta property="og:type" content="article"> -<meta property="article:published_time" content="2016-08-02T18:14:35-07:00"> +<meta property="article:published_time" content="2016-10-06T11:16:34-07:00"> <meta name="twitter:card" content="summary"> <meta name="twitter:site" content="@jekyllrb"> <meta name="google-site-verification" content="onQcXpAvtHBrUI5LlroHNE_FP0b2qvFyPq7VZw36iEY"> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "BlogPosting", "headline": "Data Files", - "datePublished": "2016-08-02T18:14:35-07:00", + "datePublished": "2016-10-06T11:16:34-07:00", "description": "In addition to the built-in variables available from Jekyll,you can specify your own custom data that can be accessed via the Liquidtemplating system.", - "logo": "https://jekyllrb.comimg/logo-2x.png", + "logo": "https://jekyllrb.com/img/logo-2x.png", "url": "https://jekyllrb.com/docs/datafiles/" } </script> <!-- End Jekyll SEO tag --> <!--[if lt IE 9]> @@ -112,164 +112,164 @@ <optgroup label="Getting Started"> - <option value="https://jekyllrb.com/docs/home/">Welcome</option> + <option value="/docs/home/">Welcome</option> - <option value="https://jekyllrb.com/docs/quickstart/">Quick-start guide</option> + <option value="/docs/quickstart/">Quick-start guide</option> - <option value="https://jekyllrb.com/docs/installation/">Installation</option> + <option value="/docs/installation/">Installation</option> - <option value="https://jekyllrb.com/docs/usage/">Basic Usage</option> + <option value="/docs/usage/">Basic Usage</option> - <option value="https://jekyllrb.com/docs/structure/">Directory structure</option> + <option value="/docs/structure/">Directory structure</option> - <option value="https://jekyllrb.com/docs/configuration/">Configuration</option> + <option value="/docs/configuration/">Configuration</option> </optgroup> <optgroup label="Your Content"> - <option value="https://jekyllrb.com/docs/frontmatter/">Front Matter</option> + <option value="/docs/frontmatter/">Front Matter</option> - <option value="https://jekyllrb.com/docs/posts/">Writing posts</option> + <option value="/docs/posts/">Writing posts</option> - <option value="https://jekyllrb.com/docs/drafts/">Working with drafts</option> + <option value="/docs/drafts/">Working with drafts</option> - <option value="https://jekyllrb.com/docs/pages/">Creating pages</option> + <option value="/docs/pages/">Creating pages</option> - <option value="https://jekyllrb.com/docs/static-files/">Static Files</option> + <option value="/docs/static-files/">Static Files</option> - <option value="https://jekyllrb.com/docs/variables/">Variables</option> + <option value="/docs/variables/">Variables</option> - <option value="https://jekyllrb.com/docs/collections/">Collections</option> + <option value="/docs/collections/">Collections</option> - <option value="https://jekyllrb.com/docs/datafiles/">Data Files</option> + <option value="/docs/datafiles/">Data Files</option> - <option value="https://jekyllrb.com/docs/assets/">Assets</option> + <option value="/docs/assets/">Assets</option> - <option value="https://jekyllrb.com/docs/migrations/">Blog migrations</option> + <option value="/docs/migrations/">Blog migrations</option> </optgroup> <optgroup label="Customization"> - <option value="https://jekyllrb.com/docs/templates/">Templates</option> + <option value="/docs/templates/">Templates</option> - <option value="https://jekyllrb.com/docs/permalinks/">Permalinks</option> + <option value="/docs/permalinks/">Permalinks</option> - <option value="https://jekyllrb.com/docs/pagination/">Pagination</option> + <option value="/docs/pagination/">Pagination</option> - <option value="https://jekyllrb.com/docs/plugins/">Plugins</option> + <option value="/docs/plugins/">Plugins</option> - <option value="https://jekyllrb.com/docs/themes/">Themes</option> + <option value="/docs/themes/">Themes</option> - <option value="https://jekyllrb.com/docs/extras/">Extras</option> + <option value="/docs/extras/">Extras</option> </optgroup> <optgroup label="Deployment"> - <option value="https://jekyllrb.com/docs/github-pages/">GitHub Pages</option> + <option value="/docs/github-pages/">GitHub Pages</option> - <option value="https://jekyllrb.com/docs/deployment-methods/">Deployment methods</option> + <option value="/docs/deployment-methods/">Deployment methods</option> - <option value="https://jekyllrb.com/docs/continuous-integration/">Continuous Integration</option> + <option value="/docs/continuous-integration/">Continuous Integration</option> </optgroup> <optgroup label="Miscellaneous"> - <option value="https://jekyllrb.com/docs/troubleshooting/">Troubleshooting</option> + <option value="/docs/troubleshooting/">Troubleshooting</option> - <option value="https://jekyllrb.com/docs/sites/">Sites using Jekyll</option> + <option value="/docs/sites/">Sites using Jekyll</option> - <option value="https://jekyllrb.com/docs/resources/">Resources</option> + <option value="/docs/resources/">Resources</option> - <option value="https://jekyllrb.com/docs/upgrading/0-to-2/">Upgrading from 0.x to 2.x</option> + <option value="/docs/upgrading/0-to-2/">Upgrading from 0.x to 2.x</option> - <option value="https://jekyllrb.com/docs/upgrading/2-to-3/">Upgrading from 2.x to 3.x</option> + <option value="/docs/upgrading/2-to-3/">Upgrading from 2.x to 3.x</option> </optgroup> <optgroup label="Meta"> - <option value="https://jekyllrb.com/docs/contributing/">Contributing</option> + <option value="/docs/contributing/">Contributing</option> - <option value="https://jekyllrb.com/docs/conduct/">Code of Conduct</option> + <option value="/docs/conduct/">Code of Conduct</option> - <option value="https://jekyllrb.com/docs/history/">History</option> + <option value="/docs/history/">History</option> </optgroup> </select> @@ -308,107 +308,136 @@ <p>Here is a basic example of using Data Files to avoid copy-pasting large chunks of code in your Jekyll templates:</p> <p>In <code class="highlighter-rouge">_data/members.yml</code>:</p> -<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="pi">-</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Eric Mill</span> +<div class="language-yaml highlighter-rouge"> +<pre class="highlight"><code><span class="pi">-</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Eric Mill</span> <span class="s">github</span><span class="pi">:</span> <span class="s">konklone</span> <span class="pi">-</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Parker Moore</span> <span class="s">github</span><span class="pi">:</span> <span class="s">parkr</span> <span class="pi">-</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Liu Fengyun</span> - <span class="s">github</span><span class="pi">:</span> <span class="s">liufengyun</span></code></pre></figure> + <span class="s">github</span><span class="pi">:</span> <span class="s">liufengyun</span> +</code></pre> +</div> <p>Or <code class="highlighter-rouge">_data/members.csv</code>:</p> -<figure class="highlight"><pre><code class="language-text" data-lang="text">name,github +<div class="language-text highlighter-rouge"> +<pre class="highlight"><code>name,github Eric Mill,konklone Parker Moore,parkr -Liu Fengyun,liufengyun</code></pre></figure> +Liu Fengyun,liufengyun +</code></pre> +</div> <p>This data can be accessed via <code class="highlighter-rouge">site.data.members</code> (notice that the filename determines the variable name).</p> <p>You can now render the list of members in a template:</p> -<figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;ul&gt;</span> +<div class="language-html highlighter-rouge"> +<pre class="highlight"><code> +<span class="nt">&lt;ul&gt;</span> {% for member in site.data.members %} <span class="nt">&lt;li&gt;</span> <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"https://github.com/{{ member.github }}"</span><span class="nt">&gt;</span> {{ member.name }} <span class="nt">&lt;/a&gt;</span> <span class="nt">&lt;/li&gt;</span> {% endfor %} -<span class="nt">&lt;/ul&gt;</span></code></pre></figure> +<span class="nt">&lt;/ul&gt;</span> +</code></pre> +</div> + <h2 id="example-organizations">Example: Organizations</h2> <p>Data files can also be placed in sub-folders of the <code class="highlighter-rouge">_data</code> folder. Each folder level will be added to a variable’s namespace. The example below shows how GitHub organizations could be defined separately in a file under the <code class="highlighter-rouge">orgs</code> folder:</p> <p>In <code class="highlighter-rouge">_data/orgs/jekyll.yml</code>:</p> -<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="s">username</span><span class="pi">:</span> <span class="s">jekyll</span> +<div class="language-yaml highlighter-rouge"> +<pre class="highlight"><code><span class="s">username</span><span class="pi">:</span> <span class="s">jekyll</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Jekyll</span> <span class="s">members</span><span class="pi">:</span> <span class="pi">-</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Tom Preston-Werner</span> <span class="s">github</span><span class="pi">:</span> <span class="s">mojombo</span> <span class="pi">-</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Parker Moore</span> - <span class="s">github</span><span class="pi">:</span> <span class="s">parkr</span></code></pre></figure> + <span class="s">github</span><span class="pi">:</span> <span class="s">parkr</span> +</code></pre> +</div> <p>In <code class="highlighter-rouge">_data/orgs/doeorg.yml</code>:</p> -<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="s">username</span><span class="pi">:</span> <span class="s">doeorg</span> +<div class="language-yaml highlighter-rouge"> +<pre class="highlight"><code><span class="s">username</span><span class="pi">:</span> <span class="s">doeorg</span> <span class="s">name</span><span class="pi">:</span> <span class="s">Doe Org</span> <span class="s">members</span><span class="pi">:</span> <span class="pi">-</span> <span class="s">name</span><span class="pi">:</span> <span class="s">John Doe</span> - <span class="s">github</span><span class="pi">:</span> <span class="s">jdoe</span></code></pre></figure> + <span class="s">github</span><span class="pi">:</span> <span class="s">jdoe</span> +</code></pre> +</div> <p>The organizations can then be accessed via <code class="highlighter-rouge">site.data.orgs</code>, followed by the file name:</p> -<figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;ul&gt;</span> +<div class="language-html highlighter-rouge"> +<pre class="highlight"><code> +<span class="nt">&lt;ul&gt;</span> {% for org_hash in site.data.orgs %} {% assign org = org_hash[1] %} <span class="nt">&lt;li&gt;</span> <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"https://github.com/{{ org.username }}"</span><span class="nt">&gt;</span> {{ org.name }} <span class="nt">&lt;/a&gt;</span> ({{ org.members | size }} members) <span class="nt">&lt;/li&gt;</span> {% endfor %} -<span class="nt">&lt;/ul&gt;</span></code></pre></figure> +<span class="nt">&lt;/ul&gt;</span> +</code></pre> +</div> + <h2 id="example-accessing-a-specific-author">Example: Accessing a specific author</h2> <p>Pages and posts can also access a specific data item. The example below shows how to access a specific item:</p> <p><code class="highlighter-rouge">_data/people.yml</code>:</p> - -<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="s">dave</span><span class="pi">:</span> +<div class="language-yaml highlighter-rouge"> +<pre class="highlight"><code><span class="s">dave</span><span class="pi">:</span> <span class="s">name</span><span class="pi">:</span> <span class="s">David Smith</span> - <span class="s">twitter</span><span class="pi">:</span> <span class="s">DavidSilvaSmith</span></code></pre></figure> + <span class="s">twitter</span><span class="pi">:</span> <span class="s">DavidSilvaSmith</span> +</code></pre> +</div> <p>The author can then be specified as a page variable in a post’s frontmatter:</p> -<figure class="highlight"><pre><code class="language-html" data-lang="html">--- +<div class="language-html highlighter-rouge"> +<pre class="highlight"><code> +--- title: sample post author: dave --- {% assign author = site.data.people[page.author] %} <span class="nt">&lt;a</span> <span class="na">rel=</span><span class="s">"author"</span> <span class="na">href=</span><span class="s">"{{ author.twitter }}"</span> <span class="na">title=</span><span class="s">"{{ author.name }}"</span><span class="nt">&gt;</span> {{ author.name }} -<span class="nt">&lt;/a&gt;</span></code></pre></figure> +<span class="nt">&lt;/a&gt;</span> +</code></pre> +</div> + @@ -481,168 +510,168 @@ <h4>Getting Started</h4> <ul> - <li class=""><a href="https://jekyllrb.com/docs/home/">Welcome</a></li> + <li class=""><a href="/docs/home/">Welcome</a></li> - <li class=""><a href="https://jekyllrb.com/docs/quickstart/">Quick-start guide</a></li> + <li class=""><a href="/docs/quickstart/">Quick-start guide</a></li> - <li class=""><a href="https://jekyllrb.com/docs/installation/">Installation</a></li> + <li class=""><a href="/docs/installation/">Installation</a></li> - <li class=""><a href="https://jekyllrb.com/docs/usage/">Basic Usage</a></li> + <li class=""><a href="/docs/usage/">Basic Usage</a></li> - <li class=""><a href="https://jekyllrb.com/docs/structure/">Directory structure</a></li> + <li class=""><a href="/docs/structure/">Directory structure</a></li> - <li class=""><a href="https://jekyllrb.com/docs/configuration/">Configuration</a></li> + <li class=""><a href="/docs/configuration/">Configuration</a></li> </ul> <h4>Your Content</h4> <ul> - <li class=""><a href="https://jekyllrb.com/docs/frontmatter/">Front Matter</a></li> + <li class=""><a href="/docs/frontmatter/">Front Matter</a></li> - <li class=""><a href="https://jekyllrb.com/docs/posts/">Writing posts</a></li> + <li class=""><a href="/docs/posts/">Writing posts</a></li> - <li class=""><a href="https://jekyllrb.com/docs/drafts/">Working with drafts</a></li> + <li class=""><a href="/docs/drafts/">Working with drafts</a></li> - <li class=""><a href="https://jekyllrb.com/docs/pages/">Creating pages</a></li> + <li class=""><a href="/docs/pages/">Creating pages</a></li> - <li class=""><a href="https://jekyllrb.com/docs/static-files/">Static Files</a></li> + <li class=""><a href="/docs/static-files/">Static Files</a></li> - <li class=""><a href="https://jekyllrb.com/docs/variables/">Variables</a></li> + <li class=""><a href="/docs/variables/">Variables</a></li> - <li class=""><a href="https://jekyllrb.com/docs/collections/">Collections</a></li> + <li class=""><a href="/docs/collections/">Collections</a></li> - <li class="current"><a href="https://jekyllrb.com/docs/datafiles/">Data Files</a></li> + <li class="current"><a href="/docs/datafiles/">Data Files</a></li> - <li class=""><a href="https://jekyllrb.com/docs/assets/">Assets</a></li> + <li class=""><a href="/docs/assets/">Assets</a></li> - <li class=""><a href="https://jekyllrb.com/docs/migrations/">Blog migrations</a></li> + <li class=""><a href="/docs/migrations/">Blog migrations</a></li> </ul> <h4>Customization</h4> <ul> - <li class=""><a href="https://jekyllrb.com/docs/templates/">Templates</a></li> + <li class=""><a href="/docs/templates/">Templates</a></li> - <li class=""><a href="https://jekyllrb.com/docs/permalinks/">Permalinks</a></li> + <li class=""><a href="/docs/permalinks/">Permalinks</a></li> - <li class=""><a href="https://jekyllrb.com/docs/pagination/">Pagination</a></li> + <li class=""><a href="/docs/pagination/">Pagination</a></li> - <li class=""><a href="https://jekyllrb.com/docs/plugins/">Plugins</a></li> + <li class=""><a href="/docs/plugins/">Plugins</a></li> - <li class=""><a href="https://jekyllrb.com/docs/themes/">Themes</a></li> + <li class=""><a href="/docs/themes/">Themes</a></li> - <li class=""><a href="https://jekyllrb.com/docs/extras/">Extras</a></li> + <li class=""><a href="/docs/extras/">Extras</a></li> </ul> <h4>Deployment</h4> <ul> - <li class=""><a href="https://jekyllrb.com/docs/github-pages/">GitHub Pages</a></li> + <li class=""><a href="/docs/github-pages/">GitHub Pages</a></li> - <li class=""><a href="https://jekyllrb.com/docs/deployment-methods/">Deployment methods</a></li> + <li class=""><a href="/docs/deployment-methods/">Deployment methods</a></li> - <li class=""><a href="https://jekyllrb.com/docs/continuous-integration/">Continuous Integration</a></li> + <li class=""><a href="/docs/continuous-integration/">Continuous Integration</a></li> </ul> <h4>Miscellaneous</h4> <ul> - <li class=""><a href="https://jekyllrb.com/docs/troubleshooting/">Troubleshooting</a></li> + <li class=""><a href="/docs/troubleshooting/">Troubleshooting</a></li> - <li class=""><a href="https://jekyllrb.com/docs/sites/">Sites using Jekyll</a></li> + <li class=""><a href="/docs/sites/">Sites using Jekyll</a></li> - <li class=""><a href="https://jekyllrb.com/docs/resources/">Resources</a></li> + <li class=""><a href="/docs/resources/">Resources</a></li> - <li class=""><a href="https://jekyllrb.com/docs/upgrading/0-to-2/">Upgrading from 0.x to 2.x</a></li> + <li class=""><a href="/docs/upgrading/0-to-2/">Upgrading from 0.x to 2.x</a></li> - <li class=""><a href="https://jekyllrb.com/docs/upgrading/2-to-3/">Upgrading from 2.x to 3.x</a></li> + <li class=""><a href="/docs/upgrading/2-to-3/">Upgrading from 2.x to 3.x</a></li> </ul> <h4>Meta</h4> <ul> - <li class=""><a href="https://jekyllrb.com/docs/contributing/">Contributing</a></li> + <li class=""><a href="/docs/contributing/">Contributing</a></li> - <li class=""><a href="https://jekyllrb.com/docs/conduct/">Code of Conduct</a></li> + <li class=""><a href="/docs/conduct/">Code of Conduct</a></li> - <li class=""><a href="https://jekyllrb.com/docs/history/">History</a></li> + <li class=""><a href="/docs/history/">History</a></li> </ul> </aside>