The desire to find an array in the Jekyll configuration file (site navigation)

In mine _config.ymlI have:

navigation:
- text: Home
  url: index.html
- text: About
  url: about.html
- text: Blog
  url: blog.html
- text: Portfolio
  url: portfolio.html

In my layout default.html, I have:

<ul class="nav-list">
  {% for link in site.navigation %}
    {% assign current = nil %}
    {% if page.url == link.url %}
      {% assign current = 'current' %}
    {% endif %}

    <li class="nav-list-item{% if forloop.first %}first{% endif %} {{ current }} {% if forloop.last %}nav-list-item-last{% endif %}">
      <a class="{{ current }}" href="{{ link.url }}">{{ link.text }}</a>
    </li>
  {% endfor %}
</ul>

For some reason this does not work. Why could this be?

+5
source share
2 answers

I just found out that you need to restart the server and start jekyll --serveragain, and the variables _config.ymlwill be available.

Then, finding this out, he returned to this page and was about to publish this answer by clicking add / show 4 more commentsand saw that it was also detected by the operator. So send it as an answer.

+4
source

: - - Ctrl + C ( CLI). ,

jekyll server -w

Jekyll, . _config.yml, . , , --safe, . , jekyll --safe build, , . jekyll doctor/jekyll hyde dev.

0

All Articles