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

陌路散爱 提交于 2019-12-23 22:25:14

问题


There is no actual link to my rss feed from the nav, but it adds a css borderon 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>

回答1:


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?



来源:https://stackoverflow.com/questions/41726078/how-do-i-exclude-rss-jekyll-feed-from-nav

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!