Hi, I ran into a weird problem with {{ page.url }}
where in my current setup, calling {{ page.url }}
anywhere else outputs the right slug, for example /
for the homepage; /about/
for the about page, and so on.
However, from my footer file, which is in the _includes
directory, and which I’m calling into other templates/layouts as {% include footer.html %}
{{ page.url }}
is blank. For this reason, when I run a conditional such as like so in the footer, I don’t get the expected active-class result:
<nav class="nav">
<h2 class="sr">{{ site.title }} Site's Minimap</h2>
<ul class="none m-0 is-horizontal nanotext is-all-caps">
{% for entry in site.data.nav %}
{% assign class = nil %}
{% if entry.slug == page.url %}
{% assign class = class | append: ' is-active' %}
{% endif %}
<li>
<a href="{{ site.url }}{{ entry.slug }}" class="{{ class }}">
{{ entry.name }}
</a>
</li>
{% endfor %}
</ul>
</nav>
Please note that the above block of code is in a nav.html
file which is being called into footer.html
.
In this footer area where {{ page.url }}
is returning blank, when I run {{ page | jsonify }}
to debug, I get a string such as "\n \n page-about\n \n "
which I have no clue what is wrong.
Elsewhere, if I run this jsonify I see all the parameters outputted correctly, so for example, within the body of the about page, I can see like "content":"","dir":"/about/","name":"about.md","path":"_pages/about.md","url":"/about/"}
So, could someone unfix me here. What might be wrong with my setup and how can I correct this error.
Thanks.