Big media library; can Hugo create symlinks?

hi,

I have quite big media library - 20GB.
On each build this media library is copied from “content” folder to “public” folder. Is there any way to tell hugo to create a symlink instead copy?
Tnx.

I’m not sure about the symlinks but I’ve used Hugo for a couple podcast websites. The .mp3 files quickly started to take up a lot of room. What I did was hosts those files separately and then link to them separately.

For example, if my Hugo site was located at https://Example.com, I hosted my files at https://files.Example.com. This allows me to just use URLs to refer to the files from within Hugo but Hugo didn’t have to build or copy those files and I didn’t need to store those big files in Git either was made git push/pull much faster.

Tnx for tip but its not option for me as I need to resize those images sometimes.

Ah okay. Then I don’t see how a symlink will work either as Hugo needs to process the images and then put them somewhere. A symlink would modify the originals. If you’re okay with that, then I’d use a proper image program on those images first. You’d want to keep any files Hugo needs to modify or generate separate from your source as you never know if it makes a mistake or you change your mind.

As far as I know hugo does not modify originals but having symlink on folder will save resized images in original folder. To avoid that it would be perfect that hugo would symlink only files and not folders. It could be done with “cp -Rs folder_src folder_dest”.

This way you can not destroy originals and you will not polute the original folders with resized images.

Hugo does not have an option for that. But we should fix these “big image library” use cases. There are several related issues here:

  • For images in leaf bundles, it would be nice if we found a good way to say: Don’t publish the original, I only want the processed variants. Since /content has solid symlink support, you could then just create symlinks from your bundle to your media library.
  • Also, if you put your media library in /assets (there are some known symlink issues here, but that can be resolved), you could get and process your images via resources.Get.
  • I recently opened up an issue about creating symlinks to avoid duplication when publishing to multiple languages. But that if symlinks from public => public, which is much easier to reason about than what you want to do (public => /foo). I have not looked into how web servers resitrict this, but from a deployment perspective it is nice to have a fully loaded zip file I can just push to a server.

I’m not sure what’s the common web server support out there for symlinks, though. I think it is turned off by default in Apache, to take one example.

+1 for the first dot
Working with page bundles - would help to not copy local asset dirs
Could we have a frontmatter entry like ignoreDir =“assets” ?

VERY DIRTY WORKAOUND
I used resources.Match “assets.*” to process the files
IF the assets directory is HIDDEN, the original files will not copied

BUT NOT PRACTICAL

NGINX follows symlinks by default: https://nginx.org/en/docs/http/ngx_http_core_module.html#disable_symlinks