Prashanth
Prashanth

Reputation: 1332

Jekyll Github pages vs Local server Liquid tags interpretation differences

I use the following liquid tags logic in a html file.

{% assign custom_share = true %}

{% for p in site.pages_list %}{% if page.url == p[1] %}
  {% assign custom_share = false %}
{% endif %}{% endfor %}

{% if custom_share %}
    This page is not in the list.
{% endif %}

And my jekyll _config.yml has a variable pages_list something like this

pages_list:       
  About: '/about'
  Archive: '/archive'
  Feed: '/atom.xml'
  Email: '/subscribe-via-email'

While these liquid tags work properly when I do jekyll serve it doesn't seem to work on github pages. Anybody knows why?

Upvotes: 0

Views: 134

Answers (2)

David Jacquel
David Jacquel

Reputation: 52829

Accessing your page list can be done with site.pages_list, not site.github.pages_list variable.

site.github contains metadatas available on github pages only. Note that those metadatas can be accessed locally with the help of github-metadata gem.

Another reason can be that your using extensionless url that are not supported for pages by current version of jekyll on Github pages (see dependencies version here)

Upvotes: 1

Prashanth
Prashanth

Reputation: 1332

The issue was with how Github Pages treated the links.

page.url produces values like /about or /archive locally, but on Github Pages it produces values like /about.html or /archive.html, even though the browser shows a link such as {{site.url}}/about and not {{site.url}}/about.html.

Fixed using filters. something like this:

{% assign custom_share = true %}

{% assign link = page.url | remove: ".html" %}

{% for p in site.pages_list %}{% if link == p[1] %}
  {% assign custom_share = false %}
{% endif %}{% endfor %}

{% if custom_share %}
    This page is not in the list.
{% endif %}

Upvotes: 0

Related Questions