# Referencing Assets from Base and Theme

**URL:** <https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017>\
**Category:** support\
**Tags:** assets\
**Created:** [April 21, 2023, 8:00pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017 "2023-04-21T20:00:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dekker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dekker/32/19299_2.png) [@Dekker](https://discourse.gohugo.io/u/Dekker)\
**Post date:** [April 21, 2023, 8:00pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/1 "2023-04-21T20:00:43Z")

</div>

I am having a problem referencing images within the assets folder, and I’m sure it is something simple I’ve missed.

```auto
base/
├── assets/
│ └── images/
│ └── CorporateLogo.png
├── layouts/
│ └── main.html
├── themes/
│ └── theme_name/
│ └── assets/
│ └── layouts/
│ └── theme.html
├── config.toml

```

If I have a config.toml that contains a reference to the “corporate logo”

```auto
SiteLogo = "images/CorporateLogo.png"

```

and my layouts/main.html has a reference to that image

```auto
{{ $image := resources.Get .Site.Params.SiteLogo }}
{{ with $image }}
      <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{ end }}

```

then all is good, image displays, no problem.

The issue is when I try to have my THEME’s theme.html have a reference to the corporate logo. If I use the same resources.Get in the theme.html, it does not find it, and returns NIL, and no image is displayed.

If I then copy/move the “logo” to `themes/theme_name/assets/images/CorporateLogo.png`, magically everything works again.

I want the “base data” to be stored in the base site, and have the theme reference these items.

Is it as simple as putting a “stub” png in the theme’s assets folder to trick HUGO into accepting them, and having the inheritance take care of the rest??

Sorry for being long-winded…

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 21, 2023, 8:12pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/2 "2023-04-21T20:12:26Z")

</div>

I don’t understand.

You directory structure shows `assets/logos/foo.png`, but your config references `images/logos/foo.png`. Why isn’t the images subdirectory present in your directory structure?

---

<div class="post-metadata">

**Author:** ![Dekker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dekker/32/19299_2.png) [@Dekker](https://discourse.gohugo.io/u/Dekker)\
**Post date:** [April 21, 2023, 8:27pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/3 "2023-04-21T20:27:06Z")

</div>

Sorry, corrected my post to be internally consistent…

assets/images/CorporateLogo.png

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 21, 2023, 8:27pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/4 "2023-04-21T20:27:48Z")

</div>

> [@Dekker](#):
>
> `SiteLogo = "images/images/CorporateLogo.png"`

? images/images…

---

<div class="post-metadata">

**Author:** ![Dekker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dekker/32/19299_2.png) [@Dekker](https://discourse.gohugo.io/u/Dekker)\
**Post date:** [April 21, 2023, 8:29pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/5 "2023-04-21T20:29:05Z")

</div>

I’ll get it right one of these times 😉  
Example should be good now.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 21, 2023, 8:32pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/6 "2023-04-21T20:32:37Z")

</div>

> [@Dekker](#):
>
> theme.html

Do you mean config.toml?

---

<div class="post-metadata">

**Author:** ![Dekker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dekker/32/19299_2.png) [@Dekker](https://discourse.gohugo.io/u/Dekker)\
**Post date:** [April 21, 2023, 8:41pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/7 "2023-04-21T20:41:14Z")

</div>

Actually here I simply meant any random theme page, trying to incorporate an image provided from a parameter in the the base website’s config.toml config file.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 21, 2023, 8:48pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/8 "2023-04-21T20:48:46Z")

</div>

I’m pretty sure you have something misconfigured. Try this:

```plaintext
git clone --single-branch -b hugo-forum-topic-44017 https://github.com/jmooring/hugo-testing hugo-forum-topic-44017
cd hugo-forum-topic-44017
hugo server

```

---

<div class="post-metadata">

**Author:** ![Dekker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dekker/32/19299_2.png) [@Dekker](https://discourse.gohugo.io/u/Dekker)\
**Post date:** [April 22, 2023, 11:08am UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/9 "2023-04-22T11:08:40Z")

</div>

Finally got a chance to test/demonstrate. Here is a git diff patch:

```auto
diff --git a/config.toml b/config.toml
index 58ce6d9..5cb0be8 100644
--- a/config.toml
+++ b/config.toml
@@ -2,3 +2,7 @@ baseURL = 'https://example.org/'
 languageCode = 'en-us'
 title = 'Hugo Forum Topic #44017'
 theme = 'foo'
+
+[params]
+imgPresident = 'images/President.png'
+imgCEO = 'images/CEO.png'
\ No newline at end of file
diff --git a/themes/foo/layouts/_default/home.html b/themes/foo/layouts/_default/home.html
index dfe37dc..4e51f51 100644
--- a/themes/foo/layouts/_default/home.html
+++ b/themes/foo/layouts/_default/home.html
@@ -15,6 +15,19 @@
   <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
 {{ end }}
 
+<p>Trying to access base site.Params from theme</p>
+<p>President:</p>
+{{ $image := resources.Get .Site.Params.imgPresident }}
+{{ with $image }}
+ <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
+{{ end }}
+<p>CEO</p>
+{{ $image := resources.Get .Site.Params.imgCEO }}
+{{ with $image }}
+ <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
+{{ end }}
+<p>End org structure</p>
+
   {{ range site.RegularPages }}
     <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
   {{ end }}

```

---

<div class="post-metadata">

**Author:** ![Dekker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dekker/32/19299_2.png) [@Dekker](https://discourse.gohugo.io/u/Dekker)\
**Post date:** [April 22, 2023, 11:12am UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/10 "2023-04-22T11:12:07Z")

</div>

Essentially for this example, I want to display the corporate president and CEO on the home page. I demonstrated below the “siteLogo” in home.html.

These images are “corporate” so they don’t really belong to one particular theme. If you change the theme, the images will stay the same.

I also tried a different route. If I added text to the “content/\_index.md”, I thought shortcodes worked in MD files?

Dang, forgot patches don’t include images… but you can fill in with anything…

Anyway, let me know what you think…

---

<div class="post-metadata">

**Author:** ![frjo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/frjo/32/18626_2.png) [@frjo](https://discourse.gohugo.io/u/frjo)\
**Post date:** [April 22, 2023, 5:10pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/11 "2023-04-22T17:10:46Z")

</div>

I agree with jmooring, you most likely have something misconfigured because the thing you describe works without issue in Hugo.

Post your repo, or an example repo where the issue occurs and we can help you out.

---

<div class="post-metadata">

**Author:** ![Dekker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dekker/32/19299_2.png) [@Dekker](https://discourse.gohugo.io/u/Dekker)\
**Post date:** [April 22, 2023, 5:16pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/12 "2023-04-22T17:16:59Z")

</div>

This exact example, with the patch, with two images in the ROOT SITE’S /assets/images (not in theme) demonstrates the e issue…

---

<div class="post-metadata">

**Author:** ![frjo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/frjo/32/18626_2.png) [@frjo](https://discourse.gohugo.io/u/frjo)\
**Post date:** [April 22, 2023, 5:47pm UTC](https://discourse.gohugo.io/t/referencing-assets-from-base-and-theme/44017/13 "2023-04-22T17:47:35Z")

</div>

And that works perfectly, no issues at all.

Placed the images in the root `assets/images`.
