forestryio / jekyll-menus

A menus (site navigation) plugin for your Jekyll website that also works with https://forestry.io (Jekyll CMS)
MIT License
134 stars 27 forks source link

Would love some examples #7

Closed todrobbins closed 6 years ago

todrobbins commented 7 years ago

I'm trying to get a simple two-level menu working in my header and having a hard time.

- Home
- Projects
  - Project 1
  - Project 2
- About
todrobbins commented 7 years ago

My menus.yml:

main:
  - title: Main
  - identifier: main
  - url: /

projects:
  - title: Projects
  - identifier: projects
  - url: /projects/

And my header.html include:

<nav>
  {% for my_page in site.menus.projects %}
    {% if my_page.title %}
      <a class="page-link" href="{{ my_page.url | relative_url }}">{{ my_page.title | escape }}</a>
    {% endif %}
  {% endfor %}
</nav>

I know I'm probably missing something obvious. 😁

envygeeks commented 7 years ago

Hi @todrobbins,

You can see format examples here: https://github.com/forestryio/jekyll-menus#examples-1 That should be

main:
  - title: Projects
    identifier: projects
    url: /projects

  - title: Home
    identifier: Home
    url: /
projects:
  - title: Project1
    url: /projects/project1
    identifier: project1
todrobbins commented 7 years ago

Thanks! And what about the corresponding snippet in header.html?

envygeeks commented 6 years ago

Hey @todrobbins sorry for the late response (actually I'm quite embarrassed at how long it took me to respond) but can elaborate what you would me to explain?

Thanks!