Lego2012
9/26/2016 - 9:27 PM

Select current Page-URL and Change: Version 1

Select current Page-URL and Change: Version 1

---
layout: generic
title:  About
active: about
---

<!-- 
I needed something simple, this is what I did.
In my front matter I added a variable called active
I have a navigation include with the following section 
-->

<ul class="nav navbar-nav">
  {% if page.active == "home" %}
    <li class="active"><a href="#">Home</a></li>
  {% else %}
    <li><a href="/">Home</a></li>
  {% endif %}
  
  {% if page.active == "blog" %}
    <li class="active"><a href="#">Blog</a></li>
  {% else %}
    <li><a href="../blog/">Blog</a></li>
  {% endif %}

  {% if page.active == "about" %}
    <li class="active"><a href="#">About</a></li>
  {% else %}
    <li><a href="../about">About</a></li>
  {% endif %}
</ul>

<!-- 
This works for me as the amount of links in the navigation are very narrow. 
-->