Is it possible to output the path to a given section?

I'm using this to define the section model for the contact page (a single):

{% set contactPage = craft.entries.section('contact') %}

But then, there doesn't seem to be a way to get the url from this model (according to section model page on the Craft website.

It seems this information does exist as on the backend there's a link to the Contact page next to the link to edit the section.

Many thanks.


The url's are always bound to entries. And with your current code, you're getting all entries in the 'contact' section, not the section itself.

But if this is a single, what you want is the url of the entry in the 'contact' section. Try this:

{% set contactPage = craft.entries.section('contact').first() %}
{{ contactPage.getUrl() }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.