# How can I get a relative URL of a resource image?

**URL:** <https://discourse.gohugo.io/t/how-can-i-get-a-relative-url-of-a-resource-image/10205>\
**Category:** support\
**Created:** [January 26, 2018, 8:16am UTC](https://discourse.gohugo.io/t/how-can-i-get-a-relative-url-of-a-resource-image/10205 "2018-01-26T08:16:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carab](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/carab/32/4841_2.png) [@carab](https://discourse.gohugo.io/u/carab)\
**Post date:** [January 26, 2018, 8:16am UTC](https://discourse.gohugo.io/t/how-can-i-get-a-relative-url-of-a-resource-image/10205/1 "2018-01-26T08:16:00Z")

</div>

Hi there !

I have an issue when getting the `.RelPermalink` of a resource while having `relativeURLs = true` in my config.

I would expect it to build a relative URL from the current context, like it does for links between pages, but instead I still get an absolute URL from the root folder.

For example, calling `.RelPermalink` on a post’s resource from the home will give:

```auto
/post/mypost/myimage.jpg

```

But I would expect it to be:

```auto
./post/mypost/myimage.jpg

```

Shouldn’t it ?  
Thank you for your time !

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [January 26, 2018, 10:34am UTC](https://discourse.gohugo.io/t/how-can-i-get-a-relative-url-of-a-resource-image/10205/2 "2018-01-26T10:34:01Z")

</div>

> [@carab](#):
>
> Shouldn’t it ?

The `relativeURLs = true` does not change the value of `.RelPermalink` in any way, but using relative links in the first place is a must if you want `relativeURLs = true` to work.

That setting does replacements of the generated HTML.

You give much to little information to determine what’s happening in your case.

---

<div class="post-metadata">

**Author:** ![Leo\_Merkel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/leo_merkel/32/3321_2.png) [@Leo\_Merkel](https://discourse.gohugo.io/u/Leo_Merkel)\
**Post date:** [January 26, 2018, 1:57pm UTC](https://discourse.gohugo.io/t/how-can-i-get-a-relative-url-of-a-resource-image/10205/3 "2018-01-26T13:57:47Z")

</div>

I have a similar case with my testsite where I can build Development, Production and Local versions with my configs. So for the local version I wanted exactly the relative path with `./` in front as you describe. My working solution in my config\_local.toml:

```auto
baseURL = "/"
relativeURLs = true
uglyurls = true

```

I call this in my `package.json` with

```auto
HUGO_ENV=local Hugo --config config.toml,config_local.toml

```

Hope this helps.
