When I’m trying to use default page.hbs as template and create a home page using content from vamsithota.me/home, I’m getting a 404 error. Below is my routes.yaml config:
Hey @vamsi3001 I think the problem might be in using the page template name, would suggest using something less generic like template: home for this case just like described in our tutorials
The routes.yaml config you have seems to be correct. For it to work, first of all, you need to make sure you have a “page” with “home” slug published and available for public access. Second, you need to create a home.hbs template in your theme and place something like the following code to be able to use dynamic content on that page:
I’ve noticed a small bug when verifying this flow, will make sure it is included in the next release (it has to do with metadata on the page throwing an error)
Still, I’m getting the same 404 error after adding a new home.hbs template, added the code you have shared and updated the routes.yaml to the following for home:
routes:
/:
data: page.home
template: home
Also, there is page with home slug published and available for public access. As you can find it here vamsithota.me/home
Hi there! Are you still having trouble with this? I think the original mistake in the yaml config may have caused this thread to get overly complicated. The routes.yaml should look like this:
Note The indenting, yaml files are sensitive to the indentation of keys and values. That should provide the home page with the data from the page with “home” as the slug. The other part is to redirect “/home/” to the home page, which can be done with redirects.json:
I’m reiterating the solution so that for newcomers, it will be easy to figure out the two approaches to the solution.
Creating a Custom Home Page
Indentation is the key here if you have trouble try to copy-paste the routes and follow the steps correctly.
Approach 1:
If you want to use the template styling, use the page editor to add content to the home page (you need to create a new home page first) that displays on your yourwebsite.com. Also, redirect the yourwebsite.com/home to yourwebsite.com. Here is the solution from @naz and with correct indentation, it works just fine.
Approach 2:
If you want to use a clean state without the header, footer and any styling but just the Title and Page Content to display from home page on yourwebsite.com. Here is the solution from @DavidDarnes and with correct indentation, it works fine.
routes.yaml - Configure it like mentioned here.
home.hbs - Add the template with content like this.
Wow awesome write up on how you made a custom home page! We may also be working on improved documentation for this very feature .
I think you can remedy this by using the canonical option in the page settings and link the page “/home” to the home page, “/” (if you put in slash it might change to the site url automatically). Hope this helps!
@DavidDarnes Overall this document is better than the previous. Except for the placement of the Snippet for HomePage don’t have any other feedback. It should have been referenced or placed when the first mention of creating home.hbs occurs in the document.
We can prevent that from happening by creating a new template in our theme called home.hbs .
When I moved the collections from vamsithota.me to vamsithota.me/blog why is the header section missing on vamsithota.me/blog as you can see in the original theme collections page of London theme.