Best way to reference an image in `/static` directory when baseURL could contain a sub-directory?

One option is to use a shortcode. So instead of this unpreferable way that you mentioned:

![alt](/gg/image/test.jpg)

You could do:

{{< img "alt" "image/test.jpg" >}}

And the shortcode definition (let’s say it’s named img.html) could be like:

<img src="/gg/{{ .Get 1 }}" alt="{{ .Get 0 }}">

Or:

<img src="{{ .Get 1 | absURL }}" alt="{{ .Get 0 }}">