pageurl can do it with a Page object, but I am not sure how to get the root page object.
The URL of the root page is /
. Just write <a href="/">
- no need to use a template tag.
(You might think that's cheating, but it's literally the definition of the root page.)
If you have your include(wagtail_urls)
line in urls.py rooted at a path other than /
, and don't want to hard-code that path in your template, you can use: {% url 'wagtail_serve' '' %}
(note the empty string after 'wagtail_serve'
).
To show the site root page in a wagtail template, add the following to your page template:
{% load wagtailcore_tags %}
<a href="{{ request.site.root_url }}">Site Url</a>
This code is deprecated. Starting with wagtail 2.9, the preferred option is {% wagtail_site %}
. View wagtail 2.9 release notes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With