Skip to content

site.archives template variable not available in archive layout #62

Open
@swashcap

Description

I’m attempting to create an archives list in a sidebar. The sidebar should appear on multiple pages, including the archive page itself. Unfortunately, the site.archives template variable doesn’t seem to be available in the archive-specified layout.

Here’s a basic example to reproduce:

_config.yml:

jekyll-archives
  enabled:
    - month
  layout: archive
  permalinks:
    month: "/archives/:year/:month/"

_layouts/archive.html:

---
layout: default

---

<h1>Archives</h1>
<ul>
  {% assign months = site.archives | where:"type", "month" %}
  {% for month in months %}
    <li>
      <a href="{{ month.url }}">{{ month.posts[0].date | date:"%b %Y" }}</a>
    </li>
  {% endfor %}
</ul>
  • OS: OS X 10.11.4
  • Ruby: 2.3.0p0
  • jekyll: 3.0.5
  • jekyll-archives: 2.1.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions