简体   繁体   中英

How Do I Exclude RSS (Jekyll-Feed) From Nav?

There is no actual link to my rss feed from the nav, but it adds a css border on top of another border in my menu, which looks ugly. So how do I remove the feed from my nav?

The jekyll-feed gem outputs an li for the feed

Nav Menu

<nav id="menu">
    <ul class="links">
        {% for page in site.pages %}
            {% if page.layout == "home" %}
                <li><a href="{{ "" | absolute_url }}">{{ page.title }}</a></li>
            {% endif %}
        {% endfor %}
        {% for page in site.pages %}
            {% if page.layout != "home" %}
                <li><a href="{{ page.url | absolute_url }}">{{ page.title }}</a></li>
            {% endif %}
        {% endfor %}
        <div class="content">
            <ul class="actions">
                <li><a href="#contact" id="contact-btn">Contact</a></li>
            </ul>
        </div>
    </ul>
    <ul class="actions vertical">
        <li><a href="#" class="button special fit">Subscribe to Newsletter</a>
        </li>
    </ul>
</nav>

Nav HTML

    <nav id="menu">
  <ul class="links">
    <li><a href="#">Home</a></li>
    <li><a href="#/about.html">about</a></li>
    <li><a href="#/archive.html">archive</a></li>
    <li>
      <a href="#/feed.xml"></a>
    </li>
    <li>
      <a href="#/feed.xslt.xml"></a>
    </li>
    <div class="content">
      <ul class="actions">
        <li><a href="#contact" id="contact-btn">Contact</a></li>
      </ul>
    </div>
  </ul>
  <ul class="actions vertical">
    <li><a href="#" class="button special fit">Subscribe to Newsletter</a>
    </li>
  </ul>
</nav>

I think the following code should work for you:

<nav id="menu">
    <ul class="links">
        <li><a href="#">Home</a></li>
        {% for page in site.pages %}
            {% if page.layout == "home" or page.url contains ".xml" %}
            {% else %}
                <li><a href="{{ page.url }}">{{ page.title }}</a></li>
            {% endif %}
        {% endfor %}
        <div class="content">
            <ul class="actions">
                <li><a href="#contact" id="contact-btn">Contact</a></li>
            </ul>
        </div>
    </ul>
    <ul class="actions vertical">
        <li><a href="#" class="button special fit">Subscribe to Newsletter</a>
        </li>
    </ul>
</nav>

Note that I removed the extra loop over the pages to make the build quicker. I also think the absolute_url statement is not needed. Are you sure you want to open a div inside an ul?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM