Search code examples
hugonetlifytoml

Why won't my Hugo site display when deploying to Netlify?


Locally, I can view my site easily and all theme changes.

However, once the site is deployed to Netlify, all I am greeted with is a blank white screen.

I tried toggling baseURL configurations to no avail. However, if I rename my _index.md file to index.md in the /content folder the contents of that file will display when deployed via Netlify.

There are no build errors in Netlify or locally.

My working files can be seen at the following GitHub repository.


Solution

  • Explanation Summary: The _index.md file at the root of your content directory is using your themes/gwynn/layouts/index.html template, but you are not telling it to display any content or data from your frontmatter.

    themes/gwynn/layouts/index.html code:

    <!DOCTYPE html>
    <html>
    <body>
      {{ range first 10 .Data.Pages }}
        <h1><a href={{ .Permalink }}>{{ .Title }}</a></h1>
      {{ end }}
    </body>
    </html>
    

    Nothing is showing up because you are displaying only the pages in your site, but both have draft: true set in the frontmatter of the pages in post.

    Solution to show Home page Title:

    themes/gwynn/layouts/index.html

    <!DOCTYPE html>
    <html>
      <head>
        <title>{{ .Title }}</title>
      </head>
      <body>
        <h1>{{ .Title }}</h1>
        {{ range first 10 .Data.Pages }}
          <h1><a href={{ .Permalink }}>{{ .Title }}</a></h1>
        {{ end }}
      </body>
    </html>
    

    To show the page links, you can set draft: false within content/post/first.md and content/post/second.md