gohugoio / hugo

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

Print error/warning and suggest solution if a page is rendered empty #947

Closed anthonyfok closed 7 years ago

anthonyfok commented 9 years ago

See http://discuss.gohugo.io/t/generated-post-page-is-empty-solved/835

This is one of the first hurdle that I ran into too, and sometimes still run into when starting a new website, or when experimenting with a new theme.

So, it would be nice if Hugo could do a quick check to see if any generated files are empty, especially public/index.html, and emit a warning/error message, and perhaps offer possible solution to the end user, e.g. check the layouts/ directory, or use a theme, etc.

bep commented 9 years ago

There are warning-loggings about this:

WARN: 2015/03/05 Unable to locate layout for page ...
anthonyfok commented 9 years ago

@bep, awesome! I didn't know that! That would be a great place to start adding helpful messages for newcomers. I will hopefully look into it deeper in a week or two after I finish my paperwork, haha!

yacoob commented 9 years ago

Conversly, hugo currently generates 0-sized files like this one just because a layout is missing. I'm not planning to add a layout for it, as I don't need that page. If empty pages is going to be an error, I'd like to get an option to kill generation of empty pages, so this kind of thing is not a generation failure.

egorse commented 9 years ago

+1 for @yacoob - the zero bytes pages are annoying. All options (warn, fatal error, or silently remove empty pages) would by nice to have.

helmbold commented 9 years ago

+1

anthonyfok commented 8 years ago

Hi all,

I have just pushed a commit 0d1d33d that would output a big fat error when the home page is empty:

ERROR: 2015/12/01 =============================================================
ERROR: 2015/12/01 Your rendered home page is blank: /index.html is zero-length
ERROR: 2015/12/01  * Did you specify a theme on the command-line or in your
ERROR: 2015/12/01    "config.toml" file?  (Current theme: "")
ERROR: 2015/12/01  * For more debugging information, run "hugo -v"
ERROR: 2015/12/01 =============================================================

and warnings for all other empty pages if hugo is run in verbose mode.

Is this a sufficient solution for this issue #947? Or should more error checking and warnings be made?

SvenDowideit commented 8 years ago

When using hugo to generate html files that are then uploaded to s3, it would be better to be able to stop these from being written to disk at all - they cause a 200 blank page, and prevent the 404 handler from showing the user something useful.

bep commented 7 years ago

This issue has been automatically marked as stale because it has not been commented on for at least four months.

The resources of the Hugo team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still valuable, please open a proposal at https://discuss.gohugo.io/.

This issue will automatically be closed in four months if no further activity occurs. Thank you for all your contributions.

bep commented 7 years ago

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

tj commented 7 years ago

FWIW I'm getting zero logs for corresponding empty pages, I can't seem to set an explicit layout either, so I just get blank pages with no explanation. A 404 would at least be better, not really sure what's going on, I don't have an empty template etc.

Ideally in development dumping a list (or logging) of the attempted layouts would be really helpful, it's really hard to debug and makes it more difficult to learn Hugo. I keep finding cases that seem like they should work just fine, but lead to resolving to the wrong template or nothing at all.

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.