# \_index.md file rendering correctly... then overwritten by \_default/single.html

**URL:** <https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059>\
**Category:** support\
**Created:** [October 21, 2024, 9:08am UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059 "2024-10-21T09:08:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![OutOfBreath](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/outofbreath/32/23153_2.png) [@OutOfBreath](https://discourse.gohugo.io/u/OutOfBreath)\
**Post date:** [October 21, 2024, 9:08am UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/1 "2024-10-21T09:08:11Z")

</div>

Hi there,

I am fairly new to HUGO, so very much still learning.

Using version: hugo v0.134.1+extended

I have come across a problem with my \_index.md file in the root of my content directory. When I run the ‘Hugo’ command - the page is rendered correctly, but later in the build process is overwritten by the template in layouts/\_default/single.html.

I can verify that it is being rendered correctly when I run ‘Hugo --ignoreCache’ and watch the file preview in macOS. I can see it generate properly… then some seconds later it is replaced with the contents of the single.html file.

I have looked through the template lookup order and I thought I understood.  
I have tried using ‘layout’ in the front matter. I have tried several different template names and locations… same result each time and I’m at a bit of a loss.

As this is my first post I am not able to post screenshots or more than a single link. I’ve included the filenames for the second and third screenshots. They are in the same folder as the first.

My content directory looks like:  
[![](https://dev.paulwood.photography/screenshots/contentfolder.jpg) ](https://dev.paulwood.photography/screenshots/contentfolder.jpg)

And my layouts folder:  
[![](https://dev.paulwood.photography/screenshots/layouts.jpg) ](https://dev.paulwood.photography/screenshots/layouts.jpg)

Current \_index.md front matter  
indexfrontmatter.jpg

From what I have read - the \_index.md file should NEVER be rendered by a single.html template (it should look for list.html if it can’t find anything else above it)… but I must be making a mistake somewhere.

Can anyone help me narrow it down? Or help me somehow see the build process in a bit more detail to understand why this is happening?

Thank you for any help  
Paul

---

<div class="post-metadata">

**Author:** ![OutOfBreath](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/outofbreath/32/23153_2.png) [@OutOfBreath](https://discourse.gohugo.io/u/OutOfBreath)\
**Post date:** [October 21, 2024, 9:18am UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/2 "2024-10-21T09:18:53Z")

</div>

To add:

All of my other pages render correctly with no issues.

If I delete the single.html template then it renders correctly - but Hugo gives me a warning (as expected) due to the missing single.html file

“WARN found no layout file for “html” for kind “page”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.”

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [October 21, 2024, 9:29am UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/3 "2024-10-21T09:29:45Z")

</div>

You are more likely to receive a prompt and accurate response if you post a link to your project’s Git repository.

See [Requesting Help](https://discourse.gohugo.io/t/requesting-help/9132).

> Let us see your code
> 
> Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
> 
> If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

---

<div class="post-metadata">

**Author:** ![OutOfBreath](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/outofbreath/32/23153_2.png) [@OutOfBreath](https://discourse.gohugo.io/u/OutOfBreath)\
**Post date:** [October 21, 2024, 9:58am UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/4 "2024-10-21T09:58:46Z")

</div>

Ah, yes.

I was hoping there would be something simple without people needing to look at my disgraceful code and git commit messages (I’m learning git as part of this process). Lol

I’ve made the repository public here: [GitHub - OutOfBreath/paulwood-photography: paulwood.photography hugo website](https://github.com/OutOfBreath/paulwood-photography)

---

<div class="post-metadata">

**Author:** ![frjo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/frjo/32/18626_2.png) [@frjo](https://discourse.gohugo.io/u/frjo)\
**Post date:** [October 21, 2024, 3:31pm UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/5 "2024-10-21T15:31:03Z")

</div>

Delete the frontmatter line `layout = "home"` from `content/_index.md` and it works as it should.

See [Template lookup order | Hugo](https://gohugo.io/templates/lookup-order/#home-templates)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [October 21, 2024, 5:36pm UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/6 "2024-10-21T17:36:36Z")

</div>

In the future, troubleshoot issues like this with the `--printPathWarnings` command line flag.

The root of the problem is this **empty** file: `content/pages/contact-us/index.md`. Because it’s empty, its `slug` value is an empty string. And you have this in your site configuration:

```plaintext
[permalinks.page]
pages = '/:slug/'

```

So when the contact-us page is published, it is written to `public/index.html`, clobbering the `public/index.html` file written by `themes/squarepixel/layouts/home.html.html`.

Recommendations:

1. As @frjo mentioned, remove the `layout` front matter field from `content/_index.md`. It’s superfluous.

2. Add front matter to `content/pages/contact-us/index.md`.

3. Delete these files:

4. Optional, but I like this organization/naming better: move `themes/squarepixel/layouts/home.html.html` to `themes/squarepixel/layouts/_default/home.html`. The resulting layout structure:

```plaintext
themes/squarepixel/layouts/
├── _default/
│ ├── baseof.html
│ ├── home.html
│ ├── list.html
│ └── single.html
├── galleries/
│ ├── latestphotos.html.html
│ ├── list.html
│ └── single.html
├── pages/
│ └── about.html.html
├── partials/
│ ├── head/
│ │ ├── css.html
│ │ └── js.html
│ ├── footer.html
│ ├── head.html
│ ├── header.html
│ ├── menu.html
│ └── terms.html
└── photos/
    └── single.html

```

---

<div class="post-metadata">

**Author:** ![OutOfBreath](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/outofbreath/32/23153_2.png) [@OutOfBreath](https://discourse.gohugo.io/u/OutOfBreath)\
**Post date:** [October 21, 2024, 8:52pm UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/7 "2024-10-21T20:52:29Z")

</div>

Sadly this didn’t work for me.

I only added the front matter to try and force the template.

Thank you for the suggestion though

---

<div class="post-metadata">

**Author:** ![OutOfBreath](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/outofbreath/32/23153_2.png) [@OutOfBreath](https://discourse.gohugo.io/u/OutOfBreath)\
**Post date:** [October 21, 2024, 8:54pm UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/8 "2024-10-21T20:54:43Z")

</div>

Thank you for the detailed reply! I would never have got that (except maybe by accident when I filled out the problem file.

Thank you also for the troubleshooting tip for the next time (I’m sure there will be a next time)

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [October 23, 2024, 8:55pm UTC](https://discourse.gohugo.io/t/index-md-file-rendering-correctly-then-overwritten-by-default-single-html/52059/9 "2024-10-23T20:55:34Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
