How to render raw .html page?

Hi,

I have a page with the following structure:

content/folder/index.html

The index.html page contains no front matter (starts and ends with <html> tags) and used to be rendered completely by itself by Hugo, without pulling any templates from anywhere. It could be accessed by going to /folder/ on the rendered site.

I recently upgraded from Hugo 0.85.0 to 0.134.3 and the pages are no longer rendered from the raw html. Instead, the entire index.html file is treated as main in some kind of a larger template.

I also have some pages with the following structure:

content/
├── folder/
│   ├── _index.md
│   ├── subfolder1/
│   │   └── index.html
│   └── subfolder2/
│   │   └── index.html

Before I upgraded Hugo, the index.html pages in subfolder1 and subfolder2 would also get rendered completely on their own and fully custom css and html. But after the upgrade, they don’t get rendered at all, with Hugo throwing 404 error when I try to navigate to folder/subfolder1/ or folder/subfolder2/ in my browser.

I’m not sure what happened after I upgraded Hugo. Would appreciate any help here. Thank you!

have a look at these

1 Like

Thank you! This does seem to be the issue.

I tried following one of the instructions and adding

{{ range .Resources.Match "**.html" }}
  {{ $publishPath := urls.JoinPath $.RelPermalink .Name }}
  {{ (.Content | resources.FromString $publishPath).Publish }}
{{ end }}

Either to the front or to the end of layouts/_default/single.html but it doesn’t seem to change anything. The .html files are still not rendered…

Right now it seems like moving these pages into /static/ folder is the only solution. However, it has an unfortunate side-effect of breaking the links, since now the pages have to all be accessed by their full file names, rather being able to rely on folder URL pulling the index.html automatically…

mmh,

rethinking - the mentioned problem a little different. it talks about resources not published.

In your case you just have a page not a resource
Keep in mind that index.* is special for hugo as it identifies a page which may have resources.

i dunno if one should do something like that …

this works for me with your structure shown above

  • list template

    {{ define "main" }}
       <h1>PAGE-LIST</h1>
       <ul>
          {{ range .RegularPages }}
             <li><a href="{{ .RelPermalink }}">{{ .File.Dir }}</a></li>
          {{ end }}
       </ul>
    {{ end }}
    
  • single template

    {{ .Content }}
    

ofc if you want to link by the title tag, without frontmatter you will have to scan the content.

maybe your file structure is incomplete but it’s worth a try

1 Like

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