Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment in first row of templates still makes the page go blank #7243

Closed
jstromergalley opened this issue May 4, 2020 · 8 comments
Closed

Comments

@jstromergalley
Copy link

jstromergalley commented May 4, 2020

What version of Hugo are you using (hugo version)?

Hugo Static Site Generator v0.69.2-EC9DCF30 windows/amd64 BuildDate: 2020-04-24T07:51:17Z

Does this issue reproduce with the latest release?

yes

Issue #6816 was closed, however this issue was never resolved. A single that starts with a comment (if that single is based on a baseof) will fail to render.

{{- /*
	-----------------------------------------
	Block Name:
		foo

	Description:
		results in 0 pages rendered
	-----------------------------------------
*/ -}}
{{- define "foo" -}}
....... some template contents ......
{{- end -}}

Removing the initial comment allows rendering. The last time this worked was v63.x

@jstromergalley
Copy link
Author

jstromergalley commented May 4, 2020

This is also a potential workaround:

{{- define "workaround" -}}{{- end -}}
{{- /*
	-----------------------------------------
	Block Name:
		foo

	Description:
		results in 0 pages rendered
	-----------------------------------------
*/ -}}
{{- define "foo" -}}
....... some template contents ......
{{- end -}}

Specifically inserting a dummy block at the beginning of the template so that the template does not "begin" with a comment.

@pamubay
Copy link

pamubay commented May 4, 2020

You can use the comment without the dash -, just simply:

{{/* 

 Comment

*/}}

AFAIK, if the comment inside a template where it use baseof, that comment block is not going to produce whitespace tho. No need to use extra - dash.

@jstromergalley
Copy link
Author

@pamubay Thanks for the heads up. We use the {{- -}} as a pattern that less technical authors can follow as a general rule. You are correct though that they can be omitted if the multi-line comment is snuggled up to the opening and closing braces.

Alas, this does not resolve the actual issue though that child templates that begin with a comment in any form will not render a result.

Rather than be stuck at 63.x we now place a dummy block

{{- define "workaround" -}}{{- end -}}

at the beginning of these files, though that feels wrong.

@regisphilibert
Copy link
Member

Alas, this does not resolve the actual issue though that child templates that begin with a comment in any form will not render a result.

Not in any form, in the form you use:

{{- /*
comment
*/ -}}

As pointed out by @jstromergalley you don't need the - and removing them IS your workaround.

Maintaining an open source project consumes a lot of time, when fixing the comment issue in baseof, it appears this superfluous syntax was not covered, by design or omission. Until someone wishes to cover it, you can simply remove the - and all will be well.

@jstromergalley
Copy link
Author

Thanks @regisphilibert . Just to be clear, these specific style of comments DO work at the start of the document...

{{/* Comment */}}

@regisphilibert
Copy link
Member

Correct.

@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. 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 relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Sep 20, 2020
@stale stale bot closed this as completed Dec 25, 2020
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants