# Image Processing Outside Folder

**URL:** <https://discourse.gohugo.io/t/image-processing-outside-folder/9887>\
**Category:** support\
**Created:** [January 7, 2018, 3:25am UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887 "2018-01-07T03:25:10Z")\
**Posts on this page:** 12\
**Page:** 2

<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 12, 2018, 2:46pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/21 "2018-01-12T14:46:56Z")

</div>

> [@talves](#):
>
> Yeah, This I understand. Just discussing the alternative use cases as in the example of Netlify’s CMS requirements to manage a media folder in one place.

Is there an issue about this in the Netlify CMS issue tracker? I.e. why should Hugo have to adapt and not the other way around?

Having images and content bundled together has lots of benefits.

---

<div class="post-metadata">

**Author:** ![talves](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/talves/32/2062_2.png) [@talves](https://discourse.gohugo.io/u/talves)\
**Post date:** [January 12, 2018, 2:49pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/22 "2018-01-12T14:49:59Z")

</div>

I never implied that Hugo would need to adapt. I suggested the solution, so all is good.

And yes we are in agreement on the page bundling. That being said, we have a diff use case and it can be handled with no changes from either Netlify or Hugo. 🙂

We were just curious why it managed the images in the same folder and you answered the reason. Thanks.

---

<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 12, 2018, 2:51pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/23 "2018-01-12T14:51:08Z")

</div>

> [@talves](#):
>
> That being said, we have a diff use case and it can be handled with no changes from either Netlify or Hugo.

Sure, but would it not be good if Netlify CMS could support page bundles? Would it not be bettter to work with them to get the best possible CMS?

---

<div class="post-metadata">

**Author:** ![talves](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/talves/32/2062_2.png) [@talves](https://discourse.gohugo.io/u/talves)\
**Post date:** [January 12, 2018, 2:53pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/24 "2018-01-12T14:53:19Z")

</div>

> [@bep](#):
>
> Sure, but would it not be good if Netlify CMS could support page bundles?

Yes. It will at some time, but for now with the issue, there is a solution for the existing HUGO/NetlifyCMS user to handle resource image resize in their current projects.

**Also:** Why not use the ability of Hugo to manage resized images in multiple locations without having them copy the image to each of those locations when they do not need bundling? The answer is they don’t have to, because the solution is to access the images in a common place for that requirement. Hugo works out of the box. 🙂

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 13, 2018, 2:24pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/25 "2018-01-13T14:24:30Z")

</div>

I am replying to myself here.

Because I’ve just tested @talves [Github repo](https://github.com/talves/hugo-resource-images) and changed the media folder into a symbolic link under `/content/` while the original folder is under `/static/`

It works all right. But the interesting part is that Hugo thinks of the symbolic link as a section.

So `/media/` does have its own URL and its contents are rendered even when under `/static/` or even `/data/`.

Now that’s interesting.

There is a[known hack](https://discourse.gohugo.io/t/would-like-to-ignorefiles-but-use-the-underlying-content/6368/10?) to disable a section’s output and naturally I’ve tried it with this /media/ folder workaround.

I’m happy to report that with the above hack `/media/`no longer renders as a section and at the same time its contents are available for `.Resources`

Of course as @bep said everything will be improved if issue [#3612](https://github.com/gohugoio/hugo/issues/3612) is resolved.

But this looks like a very promising technique since it opens up Image Processing beyond Page Bundles.

---

<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 13, 2018, 2:40pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/26 "2018-01-13T14:40:12Z")

</div>

A note to the above: If you make it a “[index.md](http://index.md)” (a regular page bundle), you can also have sub folders for your images.

---

<div class="post-metadata">

**Author:** ![talves](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/talves/32/2062_2.png) [@talves](https://discourse.gohugo.io/u/talves)\
**Post date:** [January 13, 2018, 3:30pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/27 "2018-01-13T15:30:09Z")

</div>

> [@bep](#):
>
> If you make it a “index.md” (a regular page bundle), you can also have sub folders for your images.

I did a proof **[shortcode example here](https://github.com/talves/hugo-resource-images/blob/master/layouts/shortcodes/logos-resize.html)** also. These are simple examples and there are a lot of ways to expand on them, so if you have any improvements let me know. 😄

---

<div class="post-metadata">

**Author:** ![talves](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/talves/32/2062_2.png) [@talves](https://discourse.gohugo.io/u/talves)\
**Post date:** [January 13, 2018, 3:53pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/28 "2018-01-13T15:53:35Z")

</div>

> [@alexandros](#):
>
> So /media/ does have its own URL and its contents are rendered even when under /static/

@alexandros I am curious if you put a symbolic link from `static/media-folder/` to `content/media/ `, would you now have both deployed to your `publishdir` ? Then would you suggest they have the same name?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 13, 2018, 4:04pm UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/29 "2018-01-13T16:04:15Z")

</div>

No. That would be published as `/media/media-folder/`.

But another interesting point is that your method _really_ depends upon `.GetPage "section" "media"`

If the rendering of sections is disabled with `disabledKinds` in config the only thing that is left working is that `logos-resize` shortcode.

Anyway, good workaround @talves . I might use it at some point if I need it. Thanks!

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 19, 2018, 8:22am UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/30 "2018-01-19T08:22:21Z")

</div>

With Hugo 0.33 it’s very simple to prevent the /media/ section from getting a URL.

Simply point to an existing URL in the front matter of `_index.md`.

---

<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 19, 2018, 9:18am UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/31 "2018-01-19T09:18:26Z")

</div>

> [@alexandros](#):
>
> Simply point to an existing URL in the front matter of \_index.md.

This workaround has a potential downside: Hugo uses all of your CPU cores for page rendering, so what page gets rendered first might be a lottery.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 19, 2018, 9:21am UTC](https://discourse.gohugo.io/t/image-processing-outside-folder/9887/32 "2018-01-19T09:21:48Z")

</div>

If it’s pointed to the home page or a static page directly under /content/ then that is the page that is rendered first and /media/ does not get its URL.

I tested this.

[Previous page](https://discourse.gohugo.io/t/image-processing-outside-folder/9887.md?page=1)
