gohugoio / hugo

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

plain markdown resource breaks build #12855

Closed McShelby closed 1 month ago

McShelby commented 1 month ago

Having a leaf bundle (content/posts) with Markdown resources (content/posts/res-1.md) fails to build if beginning of Markdown contains certain characters.

res-1.md

---

Not allowed to start with a dash as used in dividers `---` or bullet point items `-`.

Most likely, it got interpreted as incomplete frontmatter.

This seems like a bug, as I think a resource does not contain meta data defined inside the resource itself.

Test repo: https://github.com/McShelby/hugo-testing/tree/hugo-issue-12855

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

$ hugo version
hugo v0.134.2-1c74abd26070b0c12849550c974a9f3f1e7afb06 windows/amd64 BuildDate=2024-09-10T10:46:33Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

The used version is the latest release.

jmooring commented 1 month ago

as I think a resource does not contain meta data

Page resources with ResourceType “page” can contain front matter, which allows you to do something like this in a template:

{{ range .Resources.ByType "page" }}
  <h3>{{ .Title }}</h3>
  <h4>{{ .Params.subtitle }}</h4>
  {{ .Content }}
{{ end }}

Page resources with ResourceType “page” include Markdown, HTML, Emacs Org Mode, AsciiDoc, Pandoc, or reStructuredText (i.e., files with extension .md, .html, .org, .adoc, .pdc, .rst). See documentation for a complete list of extensions.

I think this issue should be closed. It works as designed.

McShelby commented 1 month ago

Thanks Joe.

Page resources with ResourceType “page” can contain front matter

In case this means, front matter is optional, I would consider this a bug or at least a limitation.

If front matter is mandatory for page resources, I'll close the ticket.

jmooring commented 1 month ago

Front matter is optional, but can't begin with a character that matches the characters in front matter delimiters: -, +, {.

I don't see this changing, so you might open an issue in the docs repository.

github-actions[bot] commented 1 month 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.