I've been struggling all evening with getting the urls of my singles in a menu generator. At first I thought I nailed it, but it turned out it used the title of the singles instead of the url. When I tried to get the url I an error, so clearly I'm doing something wrong.
This is the code to generate the menu:
{# generating menu #}
<nav class="nav">
<ul class="hidden">
{# Get all Sections #}
{% set sections = craft.sections.getAllSections() %}
{# Loop through all single sections #}
{% for singleSection in sections if singleSection.type == 'single' %}
{# Output #}
<li class="">
<a href="{{ singleSection.url }}">
<div class="link">{{ singleSection }}</div>
</a>
</li>
{% endfor %}
</ul>
</nav>
It is the singleSection.url
that causes the error.
Craft\SectionModel and its behaviors do not have a method or closure named “url”.
I presume the SectionModel does not have an Url, but that doesn't bring me any close to solving my problem of getting the url of single pages.