How to override main index.html

I am trying to override the main index.html the one that base URL uses. I tried creating content/index.md when I do these other pages don’t render and the menu generated by the Hugo doesn’t show in the index.html

If I remove index.md and replace it with _index.md it workes fine but then as per the documents _index.md refers to _default/list.html and index.md refers to _default/single.html, but adding the loot index.md changes the structure of the website.

So how would I override the main index.html?

The repo is at https://github.com/akshaybabloo/akshaybabloo

What do you mean by “override”?

adding contents to layouts/index.html via lets say content/index.md

Also, according to Static Index w/ Separate /blog? layouts/index.html should take contents from content/_index.md that’s not happening for me.

Your theme has a index.html file but, there’s no reference to {{ .Content }}, which is needed to pull content from the body of a markdown file.

Override the theme’s index by copying the theme file to the same place as in your project folder, and editing it. If Hugo finds a non-theme file in the same location as the theme file, the non-theme file gets precedence.

Copy the theme index to /layouts/index.html then edit to override.

1 Like

I tried that, you mean by creating /content/_index.md and use {{ .Content }} in /layouts/index.html

It’s not working

@RickCogley – His theme does have {{ .Content }} in layouts/index.html, see below:

@akshaybabloo – Found your issue. In your content/_index.md you need to set draft: false

@RickCogley – Well, scratch that, we’re both right. Looks like @akshaybabloo added it in after your comment:

Since the themes are in git repos that can easily get overwritten, I would recommend doing the override thing I mentioned above, over editing the theme directly. Of course, you can always copy the theme’s files in, instead of doing a git clone.

1 Like