Yet another: What is going on with my relationship of /content to /templating

I currently have the structure:

/content/index.md
/content/blog/_index.md
/content/blog/test-blog.md
/layouts/_default/list.html
/layouts/_default/single.html
/layouts/_default/blog/single.html
/layouts/_default/blog/list.html

http://localhost:1313/ works exactly as expected (/content/index.md data is put into /layouts/_default/single.html although if I rename this file to /layouts/index.html it doesn’t work as expected).

However http://localhost:1313/blog/test-blog/ does not.

I am not sure if this is a bug but if I run hugo server and then add or delete /content/blog/_index.md I don’t get a 404 at http://localhost:1313/blog/test-blog/ or http://localhost:1313/blog/.
BUT if I restart and don’t edit or delete the _index.md I get a 404…

Anyway even at http://localhost:1313/blog/test-blog/ (when it kinda works) It uses the /layouts/_default/single.html template not the /layouts/_default/blog/single.html template - it also doesn’t have any content but that is as expected as there isn’t the corresponding data that is in /content/index.md.

What is going on? Thanks in advance :slight_smile:


config.toml:

baseURL = "http://example.org/"
languageCode = "en-gb"
title = "My New Hugo Site"
[sitemap]
  changefreq = "monthly"
  filename = "sitemap.xml"
  priority = 0.5

test-blog.md:

+++
title = "Test Blog"

+++

/layouts/_default/blog/single.html:

it works!!! {{ .Params.title }}

/layouts/_default/single.html:

it has unfortunately used this template!!! {{ .Params.title }}

/layouts/_default/blog/single.html and /layouts/_default/blog/list.html

should be under /layouts/blog/

How do you mean under sorry?

I have moved /layouts/_default/blog/single.html to /layouts/blog/single.html and now it finds the write template but I am still having the 404 issue where I have to change the /content/blog/_index.md file

Here is an example of https://streamable.com/np38tm what I mean. I turn the server on - 404, undelete the _index.md no more 404, turn the server on and off - 404, delete the _index.md no more 404. What is going on?

can you give us a (sample) repository for help?

Check how the permalinks for the blog section are defined (in your config file).
Let hugo render all to the public directory and check out the files.

1 Like

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