On localhost/dev copy my markdown image links are behaving oddly. In one file they are parsed and turned into the expected
<img src="/image/path/file.jpg">" html syntax. In another file, they are completely ignored and simply printed as
I’m driving myself batty trying to figure out why this works in one file but not another. I’ve never run across this before in multiple hugo sites…
update - the markdown is parsed if I move it outside of its existing html
<div> - so I’m guessing blackfriday doesn’t like certain html? I’m importing a Wordpress site so there is a lot of HTML cruft that needs to be removed, but I have not yet created or modified any layouts.
further update - if I put any sort of markdown or Go templating code outside the html, then the markdown content is all parsed, except for the code outside the html, which is simply printed to the page.
OK, last update unless I find a full solution - if I include some markdown (like a link, for example) at the end of this markdown file, with NO blank lines, then the markdown images in the file are parsed. A blank link before the ending markdown, or no markdown at all at the end, and the markdown image code is NOT parsed.
That’s all for now
In the end, the answer is that stand-alone pages, unlike blog posts, which don’t have much in the way of layouts, really need to have most of the HTML stripped out and replaced with markdown, where possible. In the end, that’s got my pages 99% of the way there.
Now I just have to decide if I want a separate layout doc for each page, since they are all different layouts. Seems like there should be an easier way of doing this. Oh well.
Note that HTML is a perfectly valid content format for Hugo alongside Markdown.
So for complex HTML just use this format along with the mandatory front matter parameters.
It will make Wordpress migration much easier for you instead of fighting with Blackfriday (which by the way may be replaced at some point for a better maintained markdown processor)
I have hundreds of pages/posts with a mixture of html and markdown, mostly due to wordpress migrations. I know that this is supposed to work. But it wasn’t/isn’t on this particular set of pages. Some pages have only one markdown section, like an image link, and it works fine. Other pages won’t parse markdown unless I include some extra markdown at the very end of the file. Instead of beating my head against that wall, converting as much html to markdown as is possible seems to be an easier fix. Although, in this one page, I ended up moving to a markdown table and lost the ability to add css classes to provide a different color background to each column. Tried it the traditional html way with divs, but that killed the markdown image link parsing.
I am working on the final page which has around 30 images and am trying to wrap my head around responsive images using srcset (because I enjoy punishing myself?) lol