- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Allow Hugo to parse "plain" Markdown #6098
Comments
Basically this issue is about allowing markdown content without front matter and I also think that this would be a very useful feature in Hugo. |
@onedrawingperday Yes, that's precisely it. I work on many documentation projects in which the front matter contains nothing but a title, which could be inferred according to a hierarchy like this:
|
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. |
sounds doable. i'll take a look at it. |
@DewofyourYouth I think we need to talk a little about the "what" here first. This issue is a little bit old. From when @lucperkins created it I think the core of the problem is already solved, see https://github.com/bep/portable-hugo-links What's left in the above is the document title.
Which would mean a repeated value, not really useful. Most Markdown docs start at h2. |
@bep In my experience, most people use an h1 at the very top of the document to specify the title when they’re not specifying it via metadata. |
Yeah, I was going to ask that the issue seemed to be mostly solved. |
@DewofyourYouth I’m more proposing a render hook that would enable you to potentially determine the title via something that isn’t front matter. So you could have logic like “if the title is set via front matter use that, otherwise use the first h1 in .Content, otherwise use a titleized version of the filename.” |
OK. Sounds like a plan. @bep does that work? |
@DewofyourYouth Sadly no, as I’ve put in a bajillion hours to successfully eliminate them 😀 But I think you fully grasp the problem already. Those scripts really only did two things, changing /foo.md to /foo and inserting front matter. The first has been solved via render hooks, and allowing for zero front matter would solve the second one. So yeah, earlier in this thread I was envisioning something more hardcoded (“infer title via first header”) but later in the thread I realized that render hooks could enable you to infer the title however you like. And maybe even allow you to infer other front matter items (date, weight, etc) as well. |
We currently parse the metadata early and the content lazily and only if it's used. I'm not giving up on that for this feature, so we need to think about it. I have my plate filled with other stuff, so this needs to wait. |
I would absoluteley appreciate this feature! |
I would like to use hugo for rendering my plain markdown notes/journals. My current experience is that plain markdown pages are rendered (at least with my config) but don't show up in lists.
Makes sense. How about just falling back to a title-cased version of the filename (eg "the-story-of-pie" => "The Story of Pie"), for the moment? @bep I'd be happy to have a go at impl if so. hi @lucperkins :) |
Actually, they do, it's just that they a. have no title so the I was able to get entries without a title to show by replacing The other barrier to this being useful is lack of date ordering. Not sure if this can be worked around in templates. |
Apparently it is possible to make Hugo parse Markdown without front matter by using Front Matter Cascade See this forum post and the one below for the details: cc: @bep |
When I try to run `hugo server` right now, I get the following error: Error: Error building site: "/home/rbryant/go/src/github.com/metallb/metallb/website/content/_header.md:1:1": plain HTML documents not supported It seems like this is an issue with a more recent version of hugo. I'm using the following version from a Fedora package: Hugo Static Site Generator v0.80.0/extended linux/amd64 BuildDate: unknown This change is based on a suggested workaround in the following issue: gohugoio/hugo#7296 The workaround seems harmless, and may no longer be needed if the following issue gets resolved at some point in the future: gohugoio/hugo#6098
I work on a lot of OSS documentation projects, and I strive to use Hugo in all of them (I can point to 20+ projects that I've used Hugo for). One of the downsides of Hugo is this: many people want to be able to use a directory full of "bare" Markdown in conjunction with Hugo, but they can't, which means that they need to provide some kind of "bridging" solution that converts that Markdown into something consumable by Hugo.
By "bare" Markdown I mean Markdown with:
/docs/foo.md
rather than/docs/foo
(because the links are to Markdown pages, not rendered HTML pages).So what usually happens is that people create some kind of build pipeline using tools like Gulp.js that adds page metadata, converts links, etc. It would be fantastic if Hugo provided you the option to:
<h1>
or maybe the first header./foo.md
links to/foo
(or even make the.md
configurable).Imagine the ability to do this (just spitballing here):
hugo server --convertLinks "md" --inferTitle --source my-github-repo
As with issue #6095, I'd be happy to take on this work if others think it's a good idea. I'm not sure how useful this would be to others. I do know that it would be immensely useful to me and I can think of many projects that would benefit.
The text was updated successfully, but these errors were encountered: