Create a custom home page

Hi, I’ve just started using Hugo and have the following structure for my site:

layouts > _default > baseof.html
layouts > _default > list.html
layouts > _default > page.html
layouts > _default > single.html

I thought if I added the following file below it would automatically start using this page as the home page, and the paginated pages would use list.html but it doesn’t seem to be working.

layouts > index.html

Any help would be really appreciated!

:wink:

Put it in _defaults. I have a layouts/_default/index.html that is rendering the homepage. In the “root directory” of layouts I have only 404 templates.

Thanks a lot for the quick reply! Unfortunately that still shows the index template for each page which is paginated rather than the lists.html page within _default :confused:

Add a content/_index.md. It will use the layouts/index.html template to construct your home page.

I already have an _index.md file under the content root folder, not sure what I’m doing wrong.

I know what is wrong, but I accidentally found out using my secret mystic powers. If I reveal the answer without having seen your code, the mystic world is gonna be all over me. As a compromise, to keep the reasonable doubt going, please share your code with everyone, and I’ll pretend to only have seen it right then, and we can reveal the answer, together. :slight_smile:

2 Likes

Share you entire site. If you can’t, make a different site project you can share. That’s how we do things here.

Right now, I can’t tell you have content blocking your homepage creation, or what your pagination config options are set as, or… anything. So share your site. :slight_smile:

Hey, very late reply but I still have this issue having resisted this project again.

I’ve shared the project below:

To summarise what I’m trying to do:

  • Add a class (.post-item—primary) within the .post-list content that is only displayed on the home page (so this is not displayed on the post pages that are paginated)
  • Add content specifically for the home page (which is not displayed on the post pages that are paginated)

With regards to pagination I also have it set to 14 in the config file but it displays 12 posts, because it’s still counting the hidden posts. I’m also not sure how to fix this either/

I would really appreciate if anyone is able to help out here, I’m quite confused and have looked through the docs a lot :frowning_face: