Prestashop logo, Visit home page

Create symbolic links (symlink)


Understand the context

When deploying to a hyperlane development environment, anything that is not present:

- in mounted directories: img, override, upload, modules, mails, themes, translations, config, download

- Or versioned by .gitignore


If you need to keep large folders without versioning them (this is Git best practice), you can create symbolic links.

For example, if we have two large folders in PrestaShop:

  • presse (2.0G)
  • photos (3.9G)

We don't want to send 5.9 GB of data to our git repository. But we also don't want these folders to disappear on deploy.
So we're going to create symbolic links.

Create symbolic links

Connect by ssh from your local terminal then

Adding .gitkeep

Before you start, you need to check if you have added a .gitkeep file in the directories, then you can move on to the next step.

A .gitkeep is a file that tells git that it should not push inside the folder, but only the folder itself. It will then be taken into account in the project tree but will always be empty in the GitLab repository. On the other hand, locally it will be well filled.

We continue with the example of folders presse and photos

cd /vol/site/current
touch presse/.gitkeep
touch photos/.gitkeep

Creating symbolic links

Next we need to create two symbolic links.

Warning: only relative links

We need to move into the current PrestaShop directory, then move the folders into upload (which is a mounted directory) and create the symbolic link.

cd /vol/site/current
mv photos upload/photos
mv presse upload/presse
ln -s upload/photos photos
ln -s upload/presse presse

You will then see the symbolic links at the root by typing ll

lrwxrwxrwx 1 root root 13 Feb 20 10:16 photos -> upload/photos/
lrwxrwxrwx 1 root root 13 Feb 20 10:16 presse -> upload/presse/

Editing .gitignore

We also need to modify the .gitignore file:



Now both folders will be saved after deploy.


Was the article helpful?