HUGO

Image not inserted after updating my Hugo version

As my computer hard drive died I had to install a new version of Hugo. And as the old computer is dead I don’t know what version of Hugo I had. But in my .md file I have this code to insert an image:

<center>
[![Widrow](/images/Bernard_Widrow.jpg)](http://www-isl.stanford.edu/~widrow/)  <br><b>Bernard Widrow</b><br> <sub> Professor Emeritus, Electrical Engineering Department, Stanford University. Ph.D. - MIT</sub>
</center>

the generated HTML file after running hugo command in the public folder used to be:

<center><a href="http://www-isl.stanford.edu/~widrow/"><img src="/images/Bernard_Widrow.jpg" alt="Widrow"></a><br><b>Bernard Widrow</b><br><sub>Professor Emeritus, Electrical Engineering Department, Stanford University. Ph.D. - MIT</sub></center>

But now after running hugo command I get this in the generated html file:

<center>
[![Widrow](/images/Bernard_Widrow.jpg)](http://www-isl.stanford.edu/~widrow/)  <br><b>Bernard Widrow</b><br> <sub> Professor Emeritus, Electrical Engineering Department, Stanford University. Ph.D. - MIT</sub>
</center>

So it looks like the [! is not recognized.
How can I fix this so it creates a correct reference to the image?

Also this is the file structures I want to make sure it is correct:

site-structure

Is the location of images folder correct?

I appreciate any help.

Just a guess, try adding:

[markup.goldmark.renderer]
    unsafe = true

to your config.toml.

Thanks for the suggestion. What you suggested is already added to the config.toml and it is not working as I explained above.

Summary:

  1. Hugo uses the Goldmark markdown parser.
  2. Goldmark adheres to the CommonMark specification.
  3. The CommonMark specification describes how to identify HTML blocks. In particular, see items 6 and 7, specifically the end condition.

This is treated as one HTML block; the encapsulated markdown will be rendered as-is:

<center>
[![Widrow](/images/Bernard_Widrow.jpg)](http://www-isl.stanford.edu/~widrow/)  <br><b>Bernard Widrow</b><br> <sub> Professor Emeritus, Electrical Engineering Department, Stanford University. Ph.D. - MIT</sub>
</center>

This is treated as two HTML blocks; the encapsulated markdown will be converted to HTML:

<center>

[![Widrow](/images/Bernard_Widrow.jpg)](http://www-isl.stanford.edu/~widrow/)  <br><b>Bernard Widrow</b><br> <sub> Professor Emeritus, Electrical Engineering Department, Stanford University. Ph.D. - MIT</sub>
</center>
1 Like

woooow, it looks like if I just add one extra line after it resolves the issue?
How come it was working without that extra line before? Is there some change in Hugo that causes that?
Thanks so much for your answer @jmooring it helped a lot.

I suspect your earlier version of Hugo was using the Blackfriday markdown processor. The Blackfriday markdown processor is not compliant with the CommonMark specification.

1 Like

Thanks so much for the answer.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.