# Duplicated path in RSS(index.xml) when using RelPermalink in Image render hooks

**URL:** <https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340>\
**Category:** support\
**Tags:** possible-bug, resources\
**Created:** [January 31, 2025, 7:09pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340 "2025-01-31T19:09:35Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitra](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mitra](https://discourse.gohugo.io/u/mitra)\
**Post date:** [January 31, 2025, 7:09pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/1 "2025-01-31T19:09:35Z")

</div>

My blog’s content structure looks like this:

```yaml
- content
  - posts
    - hello_world
      - index.md
      - foo.jpg

```

Now I can easily reference images in `index.md` like this:

```markdown
![foo](foo.jpg)

```

But the problem is that when I tried to have preview of this post in home page, browser won’t be able to found the image because `<img>` in html generated by Hugo used a relative `src` by default, which is `<img src="foo.jpg">` in this case. There’s nothing at `<website>/foo.jpg` !

To address this problem, I write a Image render hooks in my theme in `layouts/_default/_markup/render-image.html`:

```auto
{{- $img := .Page.Resources.GetMatch (.Destination | safeURL) -}}
{{- if $img -}}
  {{- $resized := $img.Process "webp q75" -}}
  <img src="{{ $resized.RelPermalink }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}"{{ end }}>
{{- else -}}
  <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}"{{ end }}>
{{- end -}}

```

To prevent original jpg images being published, I added:

```yaml
build:
  publishResources: false

```

in the front matter of the post.

Everything looks good to me at first. In post page, it generated `<img src="/blog/posts/hello_world/foo_hu17796280442050758554.webp">`, same as in index.html.

But the problem is that it creates duplicated image link in `index.xml`, something looks like this:

```auto
<description>&lt;p&gt;hello_world&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://xxx.github.io/blog/blog/posts/hello_world/foo_hu17796280442050758554.webp&#34; alt=&#34;hello&#34; &gt;&lt;/p&gt;</description>

```

Here’s my `hugo.toml`:

```toml
baseURL = 'https://xxx.github.io/blog'

```

Did I missed something?

---

<div class="post-metadata">

**Author:** ![mitra](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mitra](https://discourse.gohugo.io/u/mitra)\
**Post date:** [January 31, 2025, 7:11pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/2 "2025-01-31T19:11:31Z")

</div>

I use `Permalink` as a temporarily workaround, but isn’t a bug or something?

---

<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:** [January 31, 2025, 7:16pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/3 "2025-01-31T19:16:25Z")

</div>

No, it’s not a bug. Is your site mulitlingual?

---

<div class="post-metadata">

**Author:** ![mitra](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mitra](https://discourse.gohugo.io/u/mitra)\
**Post date:** [January 31, 2025, 7:19pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/4 "2025-01-31T19:19:36Z")

</div>

No, but I deploy it on Github Pages, with `/blog` in path.

---

<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:** [January 31, 2025, 7:22pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/5 "2025-01-31T19:22:35Z")

</div>

> [@mitra](#):
>
> with `/blog` in path.

What does that mean? Is it part of the baseURL?

---

<div class="post-metadata">

**Author:** ![mitra](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mitra](https://discourse.gohugo.io/u/mitra)\
**Post date:** [January 31, 2025, 7:22pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/6 "2025-01-31T19:22:53Z")

</div>

Yeah, that is.

---

<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:** [January 31, 2025, 7:30pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/7 "2025-01-31T19:30:13Z")

</div>

Using your render hook, I am unable to reproduce the problem as described. Try it:

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

```

Then visit [http://localhost:1313/blog/](http://localhost:1313/blog/)

---

<div class="post-metadata">

**Author:** ![mitra](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@mitra](https://discourse.gohugo.io/u/mitra)\
**Post date:** [January 31, 2025, 7:34pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/8 "2025-01-31T19:34:39Z")

</div>

I’m sorry, but the problem exists in `index.xml` instead of `index.html`:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/2/3/23349d8f58e8ede67516a166b2fda9e5461727be.png)

My Hugo version:

```auto
hugo v0.141.0+extended+withdeploy linux/amd64 BuildDate=unknown VendorInfo=nixpkgs

```

---

<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:** [January 31, 2025, 8:17pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/9 "2025-01-31T20:17:22Z")

</div>

> [@jmooring](#):
>
> No, it’s not a bug.

Yes, it is.

We’re doing some transformations with RSS content and it’s fouling things up.

For now, copy your render hook to layouts/\_default/\_markup/render-image.rss.xml, then change `$resized.RelPermalink` to `$resized.Permalink`

---

<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:** [January 31, 2025, 8:28pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/10 "2025-01-31T20:28:42Z")

</div>

You can reproduce this with the HTML output format by enabling `canonifyURLs` in your site config, a setting that I hope will be deprecated someday:

[https://github.com/gohugoio/hugo/issues/4733](https://github.com/gohugoio/hugo/issues/4733)

Please thumbs up the issue.

---

<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:** [February 2, 2025, 4:16pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/11 "2025-02-02T16:16:40Z")

</div>

[https://github.com/gohugoio/hugo/issues/13332](https://github.com/gohugoio/hugo/issues/13332)

---

<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:** [February 3, 2025, 7:21pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/12 "2025-02-03T19:21:15Z")

</div>

This has been fixed, and will be available in the next release. Thanks bep.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [February 5, 2025, 7:21pm UTC](https://discourse.gohugo.io/t/duplicated-path-in-rss-index-xml-when-using-relpermalink-in-image-render-hooks/53340/13 "2025-02-05T19:21:17Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
