# Remove original resource (image) after copying?

**URL:** <https://discourse.gohugo.io/t/remove-original-resource-image-after-copying/53318>\
**Category:** support\
**Created:** [January 29, 2025, 10:22pm UTC](https://discourse.gohugo.io/t/remove-original-resource-image-after-copying/53318 "2025-01-29T22:22:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![okainov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/okainov/32/23795_2.png) [@okainov](https://discourse.gohugo.io/u/okainov)\
**Post date:** [January 29, 2025, 10:22pm UTC](https://discourse.gohugo.io/t/remove-original-resource-image-after-copying/53318/1 "2025-01-29T22:22:10Z")

</div>

Sounds like [Suggestion: Ability to rename page resources intended for download - #4](https://discourse.gohugo.io/t/suggestion-ability-to-rename-page-resources-intended-for-download/26083/4)

Unfortunately, no solution to the actual question was given there (IMO).

My use case:

- I have a blog with travel reports and photos
- For the sake of simplicity, I put original photos (hi-res, 2-5 Mb each) directly next to my post content. Similarly to the topicstarter of the linked question, the filenames in my filesystem are for for myself only. Example:

```auto
|posts
-|2022-my-mega-post
--|index.md
--|2022-01-01 21.22.35.jpg
--|2022-01-02 11.22.35.jpg

```

- In my post I had my `img` shortcode which is capable of renaming the images to something more human-readable/seo-friendly/whatever, like `{{< img "2024-08-15 16.21.04.jpg" "vennbahn-map" "Vennbahn Map" >}}` where the second param is the intented filename (`vennbahn-map.jpg`) and the third is caption

And now goes the problem - basically when I do `Resource Copy` and copy the image to the new name… It obviously does _copy_, so it leaves me with basically 2x copies of the files in the resulted `public` Hugo folder.

Is there a way to remove the original resource from `public` after copying?

---

<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 29, 2025, 11:00pm UTC](https://discourse.gohugo.io/t/remove-original-resource-image-after-copying/53318/2 "2025-01-29T23:00:56Z")

</div>

Use [build options](https://gohugo.io/content-management/build-options/). You can do this by page, by section, or by site. For example, to _not_ publish page resources for the entire site, do this in your site configuration:

```plaintext
[cascade.build]
publishResources = false

```

With this setting, you must explicitly call a page resource’s `Permalink`, `RelPermalink`, or `Publish` method to publish the resource.

I assume your shortcode looks something like this:

```plaintext
{{ with .Page.Resources.Get (.Get 0) }}
  {{ with . | resources.Copy (urls.JoinPath $.Page.RelPermalink ($.Get 1)) }}
    {{ .Publish }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ end }}
{{ end }}

```

The `.Publish` call above is a workaround for [#10584](https://github.com/gohugoio/hugo/issues/10584), applicable if you’re publishing the original page resource (which you are not, but I’d leave it in there anyway).
