[Solved] Posts in Netlify fail to load

I deployed my first Hugo site to Netlify and, while the top level of the site loads, trying to load any of my indivdual posts results in an endless loop of trying to load the page without success.

I am not sure where to start to diagnose the problem. My website works OK locally on the test server. I setup my Netlify account and built the site without error. Address: circuidipity.netlify.com

I setup the domain configuration to direct www.circuidipity.com and circuidipity.com to Netlify and it works OK.

I visit www.circuidipity.com and it works OK. Visiting www.circuidipity.com/posts/ works OK. My custom 404 page loads OK when I enter a non-existing page OK.

But if I click on any of my posts the browser enters an endless loop of trying and failing to load the page. Does anyone have any insight to offer on this? Is there any log or test that I can run to perhaps shed more light on the issue? Thanks in advance for any help!

You ought to link to your siteā€™s source, so we can see how the ocnfig and site are set up. Always do that when seeking help. :slight_smile:

Have you asked Netlify about this? I donā€™t see any reason Hugo would be causing a loop, but DNS and redirects are almost always the culprit. Also, because your local site works elsewhere, something about Netlify is probably interacting with the DNS oddly.

@maiki Thanks for responding ā€¦ Here is the link to my site source: https://github.com/vonbrownie/circuidipity

I will post an inquiry to Netlify to see if they can shed light on the matter.

Your posts have aliases set for them. It is creating double the amount of files, but also creating files that conflict with {post}/index.html page rendering.

I honestly donā€™t know if that is the issue, but Iā€™d try removing that from a post, push the changes and check.

And a question: why do your posts have aliases set for them? :slight_smile:

@maiki As per suggestion I tried removing the aliases entry on source file https://raw.githubusercontent.com/vonbrownie/circuidipity/master/content/posts/2017-07-15-virtualbox-debian-stretch.md ā€¦

Now when I navigate to the file on Netlify http://www.circuidipity.com/virtualbox-debian-stretch/ I get the message Redirecting to /virtualbox-debian-stretch and the page stops loading.

My posts have aliases set for them because they all once carried the html extension and now I am using pretty URLs under Hugo.

Netlify has their own way of doing redirects. Iā€™d drop all the aliases in front matter, and instead create _redirects for all your old URLs. You can probably figure it out with a single rule and :splat to construct yer redirect.

Or, ya know, donā€™t worry about it. You only got like 70 pieces of content. It will get reindexed quickly, and you can put a mention on the 404 about it or something. :grimacing:

I would do anything aside from using aliases for your specific case, because it doubles the amount of content files youā€™ve got, and I donā€™t know, that just annoys me. Letā€™s keep those files down!

You can search the forums, there are a bunch of Netlify and alias conversations. Let me know how it goes. :slight_smile:

1 Like

@maiki I removed the aliases from the front matter and created a _redirects file as per the Netlify HOWTO, and all the posts and pages are now loading OK! Thanks so much for your help.

I would recommend do something like in the Hugo docs:

https://github.com/gohugoio/hugoDocs/blob/master/config.toml#L17

I.eā€¦ keep the aliases in front matter and use them to create the redirects file.

1 Like

Pretty slick! The relevant _redirects template example is at index.redir.

Iā€™m posting this here because I had a similar issue with aliases and Netlify doing an endless loop, and removing them did indeed fix the problemā€¦ except:

Once I deployed to netlify with the aliases, it was very hard to get netlify to stop redirecting this. Clearing cache worked sometimes, but not always. Even reverting to a pre-Hugo version of my site would cause my pages (i.e. ā€˜/faq/ā€™ to display nothing but Redirecting to /faq).

What finally fixed this for me, was to turn on ā€œPost-processing > Asset Optimizationā€ in Netlify with all the settings (including ā€œPretty URLsā€).