How to add download link for a file in Plone

Tutorial that helps to work with file content type in Plone.

After you’ve uploaded file to Plone there are several ways to add link to it. The most simple is to insert relative or absolute link into the page or other content type. In this case browser will display the file, if it has means to do it (e.g. pdf viewer), or simply download it.

If you don’t want any other actions to be applied to the file (display, play, etc.), but always download it follow the instructions below.

1. Add specific link to the file

You can insert specific link that leads to file download directly. The same link you can see on the web page with the file itself. Add to the file address:

  • /at_download/file - if your Plone is based on Archetypes;
  • /@@download - if your Plone is based on Dexterity content types.

For example normally you would insert the following link: <a href="http://quintagroup.com/python-development-quintagroup.pdf"></a>. Insert <a href="http://quintagroup.com/python-development-quintagroup.pdf/at_download/file"> </a> and after clicking on the link pdf file will not be opened in the browser, but download will start instead.

2. Change default file alias via ZMI (for dexterity only)

You can change default behaviour for all files. Add “/manage” to the website address, go to portal types -> File. Then click on the “Aliases” tab. Replace the content of the Method field for Default alias with “@@download”.

Assign default alias as download for file in Plone

Save changes. After this whenever you insert the file address, the file download will be started immediately. To access file editing you can add “/view” or “/edit” to the file address or navigate to the file via folder_conents.

For more information on File content type properties and short URL name creation visit our tutorial on how to work with files.

Connect with our experts Let's talk