404.html, multilingual site, image path error

My default language is German, the second is English. Below my 404.html:

{{ define "main" }}
<section class="container err404">
<h1>404 - Error</h1>
<div class="err-msg">Die aufgerufene Webseite konnte nicht gefunden werden!<br>The requested website could not be found!</div>
<img src="/img/error-404-1349562.png" class="error-pict" alt="404-Error - Page not found.">

The generator changes the image path so far that one “.” is inserted before the path. This works for the default language because the 404.html is stored at the highest level public directory. For my English websites, the file from the generator appears to be in the directory /en/ copied. The image path is not correct in /en/ directory and the image will not be displayed.

Is the mistake known or do I do something wrong?

You are hardcoding the img PATH and that is not very portable as you found out.

You need to use either the absLangURL or relLangURL function in the template like so:

<img src={{ "img/error-404-1349562.png" | absLangURL }}

Also have a look at the documentation.

Thank you very much, that was the solution.

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