I’m using
{% if page.url == item.link %} active{% endif %}
And ideas how I can deal with
- domain.ext/index.html
- domain.ext/
- domain.ext
I’m using
{% if page.url == item.link %} active{% endif %}
And ideas how I can deal with
for my home page i do:
<a class="nav-item nav-link{% if page.active %} active{% endif %}" href="/">Home</a>
and then in the front matter for that page only i have:
active: true
I host on AWS S3, these both resolve to domain.ext
Probably could get index to redirect as well, but there are no links that have it so I don’t see how any one would arrive there other than manually typing it.
I normalize the page.url
first (as shown in https://github.com/flutter/website/blob/edbbd0761be3f4049c6de627980720159c2d584f/src/_includes/head.html#L16):
{% assign page_url = page.url | regex_replace: '/index$|/index.html$|\.html$|/$' -%}
links: - name: Home link: / - name: Another link link: /another-link/ - name: And so on link: /and-so-on/
<div class="nav">
<ul>
{% for link in site.data.navigation.links %}
{% assign class = "" %}
{% if link.highlight %}
{% assign class = class | append: " highlight" %}
{% endif %}
{% if link.link == page.url %}
{% assign class = class | append: " active" %}
{% endif %}
<li>
<a href="{{ site.baseurl }}{{ link.link }}"
class="{{ class }}"
{% if link.new_window %}
target="_blank"
{% endif %}>
{{ link.name }}
</a>
</li>
{% endfor %}
</ul>
</div>