# Can I reference BaseURL from content?

**URL:** <https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686>\
**Category:** support\
**Created:** [February 12, 2016, 3:41pm UTC](https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686 "2016-02-12T15:41:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omni](https://avatars.discourse-cdn.com/v4/letter/o/779978/32.png) [@Omni](https://discourse.gohugo.io/u/Omni)\
**Post date:** [February 12, 2016, 3:41pm UTC](https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686/1 "2016-02-12T15:41:48Z")

</div>

Hey all!  
Is there a way to reference static content (e.g. images) dynamically like you would in a template? i.e. using

> {{ .Site.BaseURL }})

As far as I understand the default way is to just go for

> img src=“assets/images/myimg.jpg”

This works just fine if the directory of the HTML-page never changes. In my case I worry 2 reasons for URL changes:  
(1) moving from current uglyURLs to pretty ones  
(2) going for the - hopefully released in 0.16 - multilang features which will move my page into e.g. en/page.html

If there’s no way it’s of course not the end of the world to fix these references if the page-directory ever changes.

Thanks all!  
Omni

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [February 12, 2016, 3:45pm UTC](https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686/2 "2016-02-12T15:45:03Z")

</div>

You would need to use [shortcodes](http://gohugo.io/extras/shortcodes/) for that.

---

<div class="post-metadata">

**Author:** ![Omni](https://avatars.discourse-cdn.com/v4/letter/o/779978/32.png) [@Omni](https://discourse.gohugo.io/u/Omni)\
**Post date:** [February 12, 2016, 3:59pm UTC](https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686/3 "2016-02-12T15:59:08Z")

</div>

Perfect, Thanks a lot!

If anyone else wants to use this:  
I created the file

> layouts/shortcodes/baseurl.html

with the following content:

> {{ .Page.Site.BaseURL }}

and can use it in the content as follows:

> {{\< baseurl \>}}

which outputs (in local deployment):

> [http://localhost:1313/](http://localhost:1313/)

I also think this is quite helpful if you want to reference static content from e.g. news articles which might end up in /year/month/day directory. It would save you the counting of “…/…/…/”.  
Or is that another misunderstanding on my side?

Thanks again for the quick help =)  
Omni

---

<div class="post-metadata">

**Author:** ![FollowSteph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/followsteph/32/6821_2.png) [@FollowSteph](https://discourse.gohugo.io/u/FollowSteph)\
**Post date:** [September 2, 2018, 9:20am UTC](https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686/4 "2018-09-02T09:20:02Z")

</div>

Thank you for taking the time to post your solution, this really helped a lot.

---

<div class="post-metadata">

**Author:** ![morfikov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/morfikov/32/12113_2.png) [@morfikov](https://discourse.gohugo.io/u/morfikov)\
**Post date:** [August 11, 2020, 11:03pm UTC](https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686/5 "2020-08-11T23:03:16Z")

</div>

This solved one of my major issues, thanks.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [August 12, 2020, 12:45am UTC](https://discourse.gohugo.io/t/can-i-reference-baseurl-from-content/2686/6 "2020-08-12T00:45:31Z")

</div>

Archived on August 12, 2020, 12:45am UTC


