11ty/eleventy-navigation

Support: Mystery Issue expected colon after dict key

inetbiz opened this issue · 1 comments

Error

(./_src/components/breadcrumb.njk) [Line 4, Column 24]
[11ty]   parseAggregate: expected colon after dict key (via Template render error)

Front Matter Example

eleventyNavigation:
  key: tech-seo
  title: Technical SEO

Line 4-7 breadcrumb.njk:

    {% set navPages = {{ collections.all | eleventyNavigation | eleventyNavigationToHtml | safe }} %}
    {% for crumb in navPages %}
    <li class="breadcrumb-item{% if crumb.url == page.url %} active" aria-current="page">{{ crumb.title }}{% endif %}>{% else %}<a class="pretty-link" href="{{ crumb.url | url }}">{{ crumb.title }}</a>
  {%- endfor %}

You don't want the {{ inside the {% ... %} block.

-{% set navPages = {{ collections.all | eleventyNavigation | eleventyNavigationToHtml | safe }} %}
+{% set navPages = collections.all | eleventyNavigation | eleventyNavigationToHtml | safe %}

But I think the next issue is that eleventyNavigationToHtml is going to return some beautifully formatted HTML for you:

<ul>
  <li><a href="/pages/">Technical SEO</a></li>
</ul>

… so your {% for %}...{% endfor %} loop will be looping over that HTML string, one character at a time.

You probably just want {%- set navPages = collections.all | eleventyNavigation -%} if you're trying to customize the HTML.