Hi,
Is there a shortcode I could put in a markdown file that very simply tells Hugo not to render any of the HTML inside it? Like:
+++
front matter
+++
<shortcode>
a bunch of html that should be completely untouched by the markdown rendering engine
</shortcode>
this markdown content would be rendered normally
Why?
Even though Markdown does a pretty good job not messing up HTML, it always seems to a little, and that gets in the way of a fast workflow.
This shortcode might be one half of a simple solution to the questions about (a) creating static content that can use partials and (b) creating nested, multi-level sites… I think if this works the matter will simply be a technique and no changes to Hugo would be necessary. I’ll write it up if I can make it work.
Whether or not a shortcode is used, it looks like when you put HTML in a markdown file it surrounds it with <p>…</p>. So this is another problem to overcome if the goal is to put content in content files and not store it in layouts (which seems like a worthy goal to me).
Yes - I found when I put in raw HTML, I occasionally get issues like the extra P tags and all of the comments in my HTML code come through lookling like <!-- comment -->. Which is strange because right here in the box I’m typing in right now, if I type <!-- comment --> it’s invisible, the way it should be. The markdown rendering engine on this site is different from Black Friday I suppose?
In terms of markdown adding the extra P tags, I see there’s a lot of discussion about it, not sure if it’s a bug or feature.
Also - big find - if I just change my markdown file to have an HTML file extension, Hugo doesn’t touch the HTML!! And it still passes the HTML to a template for inclusion and still honors the front matter which is where I can tell it what template to use. This is very cool and might be the solution.
I’ll just rename the content files that need to have a lot of HTML in them to filename.html.
Do you know if this is intended behavior (i.e., won’t be changed? ) Really hope so.
Yeah the commenting behavior is very strange in Black Friday , definitely beyond my ability to see the logic, unless it’s buggy. I created a comment at the top of some HTML code in a Mardown file and it was rendered invisible, then put the same at the bottom and suddenly now both comments show up in the rendered HTML as <!-- comment -->.
That is great news, thank you. Being able to have content files be HTML, and have Hugo not touch the HTML, would seem to solve all of the questions related to multi-level sites, static content with partials, homepage template behavior in other places, etc. I can write this up if you think it needs to be made clear? Or, it could be that I’m just late to the party