Image processing with dat:// urls

Following this howto
it is quite easy to set up hugo so that the site is distributed via the dat protocol.

But for some reason the safeURL trick mentioned in the blog post does not work with image processing.

Here is my code.

		{{ $preview := .Resources.GetMatch "intro" }}
		{{ with $preview }}
		{{ $scaled := .Fill "1024x610 Gaussian Center" }}
		<img class="w-100" src="{{ $scaled.Permalink | safeURL }}" alt="" />
		{{ end }}
		{{ end }}
		{{ if .Resources.GetMatch "introsvg" }}
		{{ $preview := .Resources.GetMatch "introsvg" }}
		<img src="{{ $preview.Permalink  | safeURL }}" alt="" />
		{{ end }}
		{{ $image := .Resources.GetMatch "intro*" }}
		<figcaption class="f5">
		{{ with $image }}
		<p class="f6 sans-serif b">{{ .Title }}</p><p class="f6 sans-serif">{{ .Params.copyright }}</p>

I guess that image links are created not in the same way as Permalinks.

Is it possible at all to have processed image links starting with a dat:// baseurl?

If you set baseURL in your config file to dat://some-url then I think so.

Or, you could use .RelPermalink instead then build the URL yourself. Maybe something like:

{{ printf "%s%s" site.BaseURL $preview.RelPermalink | safeURL }}
1 Like

Thanks for the hint. It works with a simple $scaled.RelPermalink.

I have to test the solution, because I want to create a https and a dat version of my website from the same source. With hugo server the http version works, so it looks good.