Reputation: 1169
I have two pages extending a base.html. home_page and works_page. I am trying to add a favicon image to the base.html. I have decided to add a favicon field to home_page which is my root page.
<link rel='icon' href='/media/{{page.favicon.file}}' />
When active page is works_page the {{page}} has no favicon field and I get an error. Is there a way to access always the root page from templates?
as {{ root_page }} maybe?
Upvotes: 0
Views: 386
Reputation: 25292
{{ request.site.root_page }}
is one way of obtaining it. However, I think the root of the problem is that favicon
shouldn't be a field of the homepage, since it's a property of the site in general, not that specific page. The wagtail.contrib.settings
module would be a good fit for this: http://docs.wagtail.io/en/v1.13/reference/contrib/settings.html
Upvotes: 1