Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
swashcap opened this issue May 9, 2016 · 3 comments
Open

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

swashcap opened this issue May 9, 2016 · 3 comments

Comments

@swashcap
Copy link

swashcap commented May 9, 2016

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
@swashcap
Copy link
Author

swashcap commented May 9, 2016

Should have noted above: months is empty in the above example. Therefore, there are no archive list items are output. I can put together a more detailed example if needed.

@stctheproducer
Copy link

Thanks for the code!

@dreamalligator
Copy link

dreamalligator commented Jan 5, 2017

I have a similar issue where a site environment variable is specified (in a generator plugin) and available throughout the site, except in the archive templates. Are we able to specify the ordering of he generators invoked by Jekyll, since jekyll-archives is possibly automatically invoked before my other generator plugin has specified a site variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants