gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.74k stars 7.53k forks source link

Reloading post with latest date and _index.md results in build error #3209

Closed halogenica closed 7 years ago

halogenica commented 7 years ago

Occurs on hugo v0.19. To reproduce, I created two posts, one on Jan 1st and one on Jan 2nd. I also created an _index.md at the root of the content directory. Then run hugo server -w. When making any modification to the latest post (the 2nd post), the first time I save, the following error is generated: ERROR 2017/03/20 22:50:41 Error while rendering "page _index.md": template: C:\Users\angelk\Desktop\website\halogenica\q\themes\after-dark\layouts\_default\baseof.html:11:12: executing "main" at <.Paginate>: error calling Paginate: invoked multiple times with different arguments

The problem only occurs on the page with the most recent date, and only if _index.md is present in the root of the content directory. When first starting the server everything behaves correctly, the error only occurs when saving the second post, and only the first time the post is saved.

content.zip

theikalman commented 7 years ago

I try to generate the issue with another theme (hugo_theme_robust) and it just works fine, only if I uses after-dark theme the error is occur. Basically hugo failed to parse the template. So I think this issue should be reported to the template project itself, unfortunately they disabled the issues.

moorereason commented 7 years ago

/cc @jhabdas

halogenica commented 7 years ago

@jhabdas Thanks for checking this out! Unfortunately you changed the wrong file above; it reproduces if you change "second.md". It only occurs if you're changing the most recent post; I suspect an out of bounds access when working with the last sorted post in the pagination code. I did reboot and try again, error still occurs. I have both windows and mac and I believe the error occurs on both systems.

halogenica commented 7 years ago

I should mention that It only reproduces with certain themes (presumably themes that make use of the _index.md at the root of the content folder). after-dark is one such theme, and the latest version of my ported theme "beautifulhugo" is another. https://github.com/comfusion/after-dark https://github.com/halogenica/beautifulhugo

halogenica commented 7 years ago

Haha how on earth does renaming index.html to index.htm fix it, and how did you think of that?

That workaround does in fact work for after-dark's theme, but unfortunately does not work for my beautifulhugo theme.

Running hugo server -w works for the first run, but on a live reload (only when modifying the most recent post) it fails catastrophically 100% of the time; hugo quits building the website after the .Paginate call. For example, using the after-dark theme with the same content I provided in this bug report, here's the front page:

From the index.html above and diffing the generated HTML you can see that the generated page is missing all content after the line {{ range (.Paginate (where .Data.Pages "Type" "post")).Pages }} from the theme. Refreshing the browser tab doesn't do anything; only killing and restarting the hugo server fixes the issue. After the first save and live reload there are no more errors generated, but the rendered html content is still broken.

bep commented 7 years ago

To all of you: I'm not sure what happens in this scenario, but I will merge #3122 in a day or two -- which will be in the Hugo 0.20 release a week or so from now. #3122 has lots of new stuff, but also a total refurbishment/unifying of all (or most) of the path/URL handling in Hugo. It fixes a lot of reported issues, and probably also a few unreported. URL handling has been the most fragile part of Hugo, too many functions doing similar stuff, and Windows hasn't helped, either.

martinhoefling commented 7 years ago

Seems as renaming index.html -> index.html also "solves" the issue for the hugo-tranquilpeak-theme.

theikalman commented 7 years ago

That's strange :smile:

halogenica commented 7 years ago

Wanted to comment that renaming the extensions from .html to .htm actually does work around the issue on my theme too, I just didn't realize at first I had to do it on multiple files (both index.html and list.html in my case).

Unfortunately, not fixed with the latest 0.20 release.

halogenica commented 7 years ago

I found out today that renaming the extension from html to htm does fix windows, but actually causes nothing to be built on MacOS.

@bep Currently this bug is marked as "Can't Reproduce" but since it has indeed been reproduced by a few people in this thread, and it is still broken as of the latest version of Hugo, can we please change the tag on this bug? Just to recap, as @jhabdas pointed out above, the problem occurs when:

bep commented 7 years ago

@halogenica I'm pretty sure that this issue was solved in Hugo 0.20.2.

halogenica commented 7 years ago

@bep Thank you! Indeed this does appear fixed in 0.20.2 (which is also when renaming html to htm stopped working). This can now be closed.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.