Markdown insert base64 image error: file name too long

I converted the image to a base64 string and inserted it into a markdown file. When I use the hugo command to generate a website, I get an error message stating that the file name is too long.
Before that I was using the stack theme and the site was working fine, then I switched to the blowfish theme and I had this problem.
I would like to know how to fix this?

error log:

Error: error building site: "/src/content/posts/blog.md:1:1": "/src/themes/blowfish/layouts/_default/_markup/render-image.html:31:71": execute of template failed: template: _markup/render-image.html:31:71: executing "_markup/render-image.html" at <resources.Get>: error calling Get:  "my base64 string" file name too long

hugo version:

hugo v0.147.8-10da2bd765d227761641f94d713d094e88b920ae+extended linux/amd64 BuildDate=2025-06-07T12:59:52Z VendorInfo=hugomods

i dont get what you exactly did here.

both themes use the old template file structure but your version states 147.8.

maybe just give 145 a try.

nevertheless to get here you will have to show something . best share your repo and point out details on the image and markdown to track.

switching a theme is usually more than just replacing it…so if it’s not related to the hugo version your changes to adapt may play its part.

The blowfish theme uses a custom image render hook to convert Markdown image elements to HTML.

Although not related to your problem, this render hook generates invalid HTML because it wraps the figure element within a paragraph element. The theme author needs to fix that.

Your problem…

Unless the image destination begins with https, the image render hook interprets the image destination as a file path, and attempts to find a page resource or a global resource with that path. The length of your data URI exceeds the operating’s system path length limit… hence the error.

To make data URI’s work with the blowfish theme, the theme author would need to make some changes to the render hook.


Also note that Hugo’s embedded image render hook does not handle data URIs either, but I’m not sure that’s something we want to change given the rarity of this use case.

2 Likes