<div class="navbar-wrapper" data-spy="affix" data-offset-top="15">
  <div class="container-fuild">

    <nav class="navbar navbar-default">
      <div class="container">

        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-left" href="/"><span class="navbar-brand">Watchout!</span></a>
        </div>

        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            {% for cat in site.data.categories %}
              {% if cat.subcategories != nil %}
              <li class = "dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ cat.name | uppercase }} <span class="caret"></span></a>
                <ul class="dropdown-menu">
                  {% for subcat in cat.subcategories %}
                   {% if site.categories[subcat.name] != nil %}
                    <li><a href="/category/{{ subcat.name }}/">{{ subcat.title | uppercase }}</a></li>
                    {% endif %}
                  {% endfor %}
                </ul>
              </li>
              {% elsif  site.categories[cat.name] != nil%}
              <li><a href="/category/{{ cat.name }}/">{{ cat.name | uppercase }}</a></li>
              {% endif %}
            {% endfor %}
          </ul>
        </div>
      </div>
    </nav>
  </div>
</div>

