Quick Tip for Symbolic Links


Assuming you have a created a local symlink under /assets/ that points to an img directory under /static/img because you need to process images on the fly with .resources.Get

You will discover that while everything works fine locally, if you deploy to Netlify the build will fail because the symlink on your remote repo needs to be: /opt/build/repo/static/img for the Netlify Build to work.

So how can you keep 2 different versions of this symlink for local development and for the Netlify Build in your remote.

.gitignore will not work because the symlink has already been committed to production.

Instead use the following command at the root of your Hugo project:
git update-index --assume-unchanged assets/img

And now you can have 2 different versions of that symlink and git will not complain.

If you need to undo the above command you can use git update-index --no-assume-unchanged assets/img

And that’s all there is to it.