Home page URL

Skip to first unread message

Matt

unread,
Oct 8, 2014, 10:29:52 AM10/8/14
to wag...@googlegroups.com
Coming from Mezzanine, I'm used to setting my home page URL as '/'. However, Wagtail doesn't seem to allow this, meaning I have to set my home page URL to 'home'. This becomes a problem when linking to the home page via a foreign key to the page model (using the PageChooserPanel). Selecting the home page inserts a link to '/home/' which just gives a 404 error on my site. I must be missing a trick....?

Matthew Westcott

unread,
Oct 8, 2014, 10:58:08 AM10/8/14
to wag...@googlegroups.com
I'm guessing that you have a link to 'page.url_path' within your template. You should use the tag {% pageurl page %} instead:
http://wagtail.readthedocs.org/en/latest/core_components/pages/writing_templates.html#pageurl

Every page, including the homepage, has to have a non-empty 'slug' - I assume this is what you're referring to when you mention setting your home page URL to 'home' - however, if you have a Site record pointing to that homepage (which is how it's set up by default, but see /django-admin/ -> Sites if in doubt) then URLs will be generated based on their paths relative to that homepage, meaning that the homepage itself receives a URL of '/', and a child of it would receive a URL of '/some-child/' despite its location in the tree being '/home/some-child/'. Hope that makes sense!

- Matt

Matt

unread,
Oct 9, 2014, 4:14:11 AM10/9/14
to wag...@googlegroups.com
Ah that will be it!

Now I have a slightly different homepage-related problem! I've started a new project, gone into the admin, deleted the 'Welcome to Wagtail' page (which was showing on the front end at the root URL) and created a new home page with slug 'home' (as a child of the site root) and published it, but I just get a 404 on the front end at the root URL or /home/. I'm sure I did this before without any problem, but maybe I've missed something...?

Matt

unread,
Oct 9, 2014, 4:16:18 AM10/9/14
to wag...@googlegroups.com
Oh, looked in djang-admin/sites and there aren't any! I guess deleting the only page in an existing site also deletes the site!
Reply all
Reply to author
Forward
0 new messages