htmljekyllliquidjekyll-paginator

Jekyll creating navigation for blog pages


I am using jekyll-pagination on a site I am working on. I have a loop for a navbar, that loops through the sites pages, and adds them to the navbar. The navbar is picking up the extra paginated pages from the blog, and adding the "Blog" to the navbar over and over again. Is there anyway to only have "Blog" show up once, and the additional blog pages be linked only in the blog?

Here is a grab of the navbar:

enter image description here

Here is the code for the navbar:

<ul class="nav navbar-nav navbar-right">
    {% assign mypages = site.pages | sort: "order" %}
    {% for page in mypages %}
        <li>
            <a href="{{ page.url | absolute_url }}">{{ page.title }}</a>
        </li>
    {% endfor %}
</ul>

Solution

  • After playing with it I found out what I needed to do. I made a folder under _site and called it _data, within that I made a file called nav.yml and added the following:

    docs_list_title: someName
    docs:
    
    - title: Home
      url: index.html
    
    - title: About
      url: about.html
    
    - title: Blog
      url: /blog/index.html
    

    Then in my layout I changed the for loop to the following:

    {% for item in site.data.nav.docs %}
        <li>
            <a href="{{ item.url | absolute_url }}">{{ item.title }}</a>
        </li>
    {% endfor %}