Wagtail: Changing the template for the default root page

Created on 3 Nov 2017  路  3Comments  路  Source: wagtail/wagtail

Issue Summary

When starting the server for the first time, there is a default site which has a default root page. Both are automatically created.
This page (the root of the default site) is not a Page model because none exists until the user creates them.
That causes the root page to use the "page.html" template from the "wagtailcore" dir which only contains the following:

<!DOCTYPE HTML>
<html>
    <head>
        <title>{{ self.title }}</title>
    </head>
    <body>
        <h1>{{ self.title }}</h1>
    </body>
</html>

I wanted to use the root page as the root page of my site, but I didn't find a way to change the type of the page so that it's template will change to a custom template.
The way I fixed it was to make class Index(Page) (which uses a custom template), create a new page of type Index and then set it to be the root of my site.

I think there should either be an easier way to do this. (If there already is, then it isn't easy to find...)

Steps to Reproduce

I created a new Django project and then followed the instruction on how to add Wagtail to an existing project.

Technical details

  • Python version: 3.6
  • Django version: 1.11.6
  • Wagtail version: 1.13
  • Browser version: Irrelevant.
Enhancement

Most helpful comment

@gasman
I think that in any case the process of creating a custom root page should be documented in the tutorial as an optional / recommended step. I doubt that anyone would want to stick with the default template.
It could be very confusing for beginners. (like me)

These are the options I could think of:

  • The default root page could search for it's template in the user's templates under a specific name like "root.html" or "default.html", that way the user could easily change the template to a custom one.
  • There will be no default root and when users create the first page they will need to choose which type of page that will be.

What do you think?

All 3 comments

Thanks for the report @lirlocker! Yep, no real argument here - the process for integrating Wagtail into an existing project is definitely less polished than starting a project from Wagtail's built-in template. (The project template comes with an editable HomePage model and migrations for switching out the default wagtailcore.Page instance for one of those; when working with an existing project, we're limited in our ability to insert those kind of things into the project codebase.)

Can you give an outline of what your ideal workflow would look like here? Bear in mind that in the _general_ case, a method for changing one page type to another would be a pretty hard thing to achieve, since there's no well-defined way of translating the fields from the old page model to the new one. (In this case it's a bit easier, since we're starting from a model with no fields beyond the basic title etc - but that still leaves open the question of how to deal with required fields in the target model.)

@gasman
I think that in any case the process of creating a custom root page should be documented in the tutorial as an optional / recommended step. I doubt that anyone would want to stick with the default template.
It could be very confusing for beginners. (like me)

These are the options I could think of:

  • The default root page could search for it's template in the user's templates under a specific name like "root.html" or "default.html", that way the user could easily change the template to a custom one.
  • There will be no default root and when users create the first page they will need to choose which type of page that will be.

What do you think?

Hi, I'm new to Wagtail. Googling how to change the default root page lead me to this issue. @gasman Any progress on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

letops picture letops  路  3Comments

alexgleason picture alexgleason  路  3Comments

BertrandBordage picture BertrandBordage  路  3Comments

contactr2m picture contactr2m  路  3Comments

tmsndrs picture tmsndrs  路  3Comments