The embeded image render hook removes URI fragment of src attribute

Hi, I use the following code to center an image:

![](images/figuer-1.png#center)

It works with Hugo v0.115. However, after I upgrade Hugo to v0.124, the image is not centered anymore.

After some tests, I’ve found that it’s because Hugo’s built-in image hook removed the URI fragment #center when converting markdown to HTML.

Has anyone experienced the same issue?

I’ve written a blog post to describe the issue and workaround:

I’d like to know is this my misunderstanding? Or is it a bug in Hugo?

We retain the fragment and query string in the embedded link render hook:

https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/_markup/render-link.html#L12-L17

But we don’t do that in the embedded image render hook:

https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html

It’s just an oversite. We (I) did not expect that scenario.

I’ll log an issue and get it fixed.

1 Like

https://github.com/gohugoio/hugo/issues/12468

https://github.com/gohugoio/hugo/pull/12469

Please subscribe to the pull request above and update your blog post when it’s merged and released. The fix should be available in the next build, which I suspect will happen in the next couple of weeks or so.

1 Like

Hi @jmooring , thanks for your quick support!
I’ve subscribed to the pull request. I will update my blog post when it’s merged and released.
Thank you