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

Question - Archive layout items #285

Closed
dpron opened this issue Apr 25, 2016 · 8 comments
Closed

Question - Archive layout items #285

dpron opened this issue Apr 25, 2016 · 8 comments
Assignees
Milestone

Comments

@dpron
Copy link

dpron commented Apr 25, 2016

I'm using jekyll-archives and am trying to get the archive-taxonomy layout to include the author sidebar as well as a default header image.

Unfortunately, when I set author_profile: true, it doesn't include the author sidebar.

I also tried adding the block of includes around page__hero that is present in other layouts, but it doesn't seem to pick up the values from adding header:/image: to the yaml of the archive-taxonomy.html layout.

Any hints?

@mmistakes
Copy link
Owner

Where were you adding author_profile: true? I just did a test and by changing author_profile: false to true in _layouts/archive-taxonomy.html, the side bar for all the pages Jekyll Archives creates shows up.

jekyll-archives-author-sidebar

To use the page__hero include with the archive-taxonomy.html layout you'll need to do some customizing. That include is pulling in values from a post/page's YAML Front Matter. If you add YAML Front Matter to the layout that's not really page data as far as Jekyll is concerned but layout data.

For example if in archive-taxonomy.html you have:

layout: default
author_profile: true
your_variable: "Some data here."

To access it you'd use {{ layout.your_variable }}. So in theory you'd have to modify all of the page.header variables in the page-hero.html include to use layout.header instead.

I haven't worked much with layout variables but I have seen a lot of weird behaviors with them. Depending on which version of Jekyll you're using it may or may not work... and/or inherit properly in other layouts. Just something to be mindful of.

@dpron
Copy link
Author

dpron commented Apr 25, 2016

Yup, I changed author_profile from false to true and it doesn't seem to make a difference.

If it matters, here's my archives section from _config.yml

# Archives
#  Type
#  - GitHub Pages compatible archive pages built with Liquid ~> type: liquid (default)
#  - Jekyll Archives plugin archive pages ~> type: jekyll-archives
#  Path (examples)
#  - Archive page should exist at path when using Liquid method or you can
#    expect broken links (especially with breadcrumbs enabled)
#  - <base_path>/tags/my-awesome-tag/index.html ~> path: /tags/
#  - <base_path/categories/my-awesome-category/index.html ~> path: /categories/
#  - <base_path/my-awesome-category/index.html ~> path: /
#categories:
#  type: jekyll-archives
#  path: /categories/
#tags:
#  type: jekyll-archives
#  path: /tags/
# https://github.com/jekyll/jekyll-archives
jekyll-archives:
  enabled:
    - categories
    - tags
  layouts:
    category: archive-taxonomy
    tag: archive-taxonomy
  permalinks:
    category: /categories/:name/
    tag: /tags/:name/

@dpron
Copy link
Author

dpron commented Apr 25, 2016

Also, if it matters - versions: jekyll 3.1.3, jekyll-archives 2.1.0

@mmistakes
Copy link
Owner

Not sure if this will make a difference but you forgot to uncomment a few things.. specifically the categories and tags options. This is what I used in my quick test.

# Archives
#  Type
#  - GitHub Pages compatible archive pages built with Liquid ~> type: liquid (default)
#  - Jekyll Archives plugin archive pages ~> type: jekyll-archives
#  Path (examples)
#  - Archive page should exist at path when using Liquid method or you can
#    expect broken links (especially with breadcrumbs enabled)
#  - <base_path>/tags/my-awesome-tag/index.html ~> path: /tags/
#  - <base_path/categories/my-awesome-category/index.html ~> path: /categories/
#  - <base_path/my-awesome-category/index.html ~> path: /
categories:
  type: jekyll-archives
  path: /categories/
tags:
  type: jekyll-archives
  path: /tags/
# https://github.com/jekyll/jekyll-archives
jekyll-archives:
  enabled:
    - categories
    - tags
  layouts:
    category: archive-taxonomy
    tag: archive-taxonomy
  permalinks:
    category: /categories/:name/
    tag: /tags/:name/

Do you have a public repo somewhere that I could look at? It's probably something simple you're missing as I was able to get it working without much effort.

@dpron
Copy link
Author

dpron commented Apr 26, 2016

Yes - I just put it up here: https://github.com/dpron/dpron.com-2016

@mmistakes
Copy link
Owner

Ok figured it out. As mentioned up a few responses page.author_profile won't work because archive-taxonomy.html is a layout and not a page.

The conditional that evaluates author_profile was only looking for it in the page. I added some additional or clauses to the conditional and that brings it in. If you want to fix it now without waiting for me to update the theme do the following:

1. In author-taxonomy.html YAML Front Matter flip to true... author_profile: true.
2. Change _includes/sidebar.html to the following (line 3 and 5 changed)

{% include base_path %}

{% if page.author_profile or layout.author_profile or page.sidebar %}
  <div class="sidebar sticky">
  {% if page.author_profile or layout.author_profile %}{% include author-profile.html %}{% endif %}
  {% if page.sidebar %}
    {% for s in page.sidebar %}
      {% if s.image %}
        <img src=
        {% if s.image contains "http" %}
          "{{ s.image }}"
        {% else %}
          "{{ s.image | prepend: "/images/" | prepend: base_path }}"
        {% endif %}
        alt="{% if s.image_alt %}{{ s.image_alt }}{% endif %}">
      {% endif %}
      {% if s.title %}<h3>{{ s.title }}</h3>{% endif %}
      {% if s.text %}{{ s.text | markdownify }}{% endif %}
    {% endfor %}
    {% if page.sidebar.nav %}
      {% include nav_list nav=page.sidebar.nav %}
    {% endif %}
  {% endif %}
  </div>
{% endif %}

Thanks for helping to identify this bug. 😄

@mmistakes mmistakes added this to the 3.1.3 milestone Apr 26, 2016
@mmistakes mmistakes self-assigned this Apr 26, 2016
@dpron
Copy link
Author

dpron commented Apr 26, 2016

Thanks! I wonder why it worked on your test above though?

Always glad to help find bugs

@mmistakes
Copy link
Owner

Could have been the version of Jekyll I was using. When I tried your repo you had a newer version that I updated to. I know at one point YAML Front Matter in a layout worked with {{ page.var }} but that was a bug and it was fixed eventually.

That's probably why I didn't notice it originally.

sobkowiak pushed a commit to sobkowiak/sobkowiak.github.io-new that referenced this issue Apr 29, 2016
sobkowiak pushed a commit to sobkowiak/sobkowiak.github.io-new that referenced this issue Apr 29, 2016
sobkowiak pushed a commit to sobkowiak/sobkowiak.github.io-new that referenced this issue Apr 29, 2016
jluccisano added a commit to jluccisano/jluccisano.github.io that referenced this issue May 6, 2017
makaroniame added a commit to makaroniame/makaroniame-old.github.io that referenced this issue May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants