Is it possible to define `staticDir` param to be nested location?

I’ve looked here, and seen how the directory structure looks generally and also how static files are treated. I’m using the hugo-universal-theme as a starting point.

What confuses me however is that:

staticDir = ["static"]

[params]
    logo = "img/logo.png"

Is not equivalent to

staticDir = ["static/img"]

[params]
    logo = "logo.png"

In my build the former compiles correctly, while the later has a broken image link. My use case question is, is there a way to reference an image in the theme submodule instead of the site root static folder? i.e. instead of the logo being at static/img/logo.pngm can i make the logo param reference an image at themes/hugo-universal-theme/static/img/logo.png? Or a similar arbitrary location?

This should be possible. It seems that hugo-universal-theme sets the logo in (its nav.html partial](https://github.com/devcows/hugo-universal-theme/blob/master/layouts/partials/nav.html).

There in line 8 is the logo variable used:

<img src="{{ .Site.BaseURL }}{{ .Site.Params.logo }}" alt="{{ .Title }} logo" class="hidden-xs hidden-sm">

You can change that line to whichever path you want to use for the logo.

If you put logo.png in the /static/static/ folder and set the logo variable to logo.png, then this should work too:

<img src="{{ .Site.BaseURL }}/static/{{ .Site.Params.logo }}" alt="{{ .Title }} logo" class="hidden-xs hidden-sm">

(Untested since I don’t use hugo-unversal-theme. But hope this helps nonetheless.)

1 Like