Skip to content

E-book Downloads

Offering free sample e-books (or e-short stories) is a good way to give potential customers a hopefully addicting taste of your work, or to give them incentive to subscribe to your mailings. Here’s how to do it.

Add E-Book Files to Your Media Library

E-books are stored in your media library, alongside any images you’ve uploaded. You can add them in advance, or on the fly while editing a page.

To add them in advance, go to your dashboard’s Media screen and click the Add New button. Upload the file the same way you would a photo.

The Upload Security Error

If your attempt to add a file to the media library succeeds, skip ahead. This section is about how to deal with the error message, “Sorry, this file type is not permitted for security reasons.”

WordPress only lets you upload certain file types; others are blocked with this message. E-book files are actually safe; the server just might not know that, so you have to tell it these files are OK.

Note: Some types of files are risky—EXE files for instance—but since you won’t let the general public add files to your site, the main risk is for your visitors, whether they trust you to not distribute malware.

To let yourself upload unsupported file types, use the plugin WP Add Mime Types by Kimiya Kitani. My setup tool gives you the option to install this, and also configures its settings to allow e-Book file types. You might need to activate it from the Plugins screen.

Once active, the plugin adds a new menu item in the dashboard, Settings > Mime Type Settings. The top section lists which file types are already allowed.

To let the server recognize additional types as safe, scroll to the bottom and look for the Add Values field. If they are not already present, add the following lines:

epub = application/epub+zip
mobi = application/x-mobipocket-ebook
azw|azw3 = application/vnd.amazon.ebook

Note: the character between azw and azw3 is a vertical bar, which on most keyboards is a shifted “\”. This indicates either file extension might be used for that file type.

Click Save Changes. Your additions will appear in the list, and now you can upload these file types to the Media Library, as shown in the next section.

If the file you’re trying to upload isn’t one of the types I just mentioned, a web search like “epub mime type” will tell you what MIME type name goes to the right of the “=” for a given file extension.

Here’s an example of adding downloadable e-Book files. The goal is to have a thumbnail image of a book cover and a short blurb, with download links for EPUB, MOBI, and PDF versions of a sample file, which, when clicked, prompt you to save the download.

You’ll do this differently depending whether you’re using the Block editor on a page or post, or the Classic editor (for instance, in a Text widget).

File Attachment in the Classic Editor

If you’ve chosen to use the Classic editor for posts and pages, or if you’re inserting a download link in a place where Classic is always used, like a Text widget, if the file isn’t already in the media library, use Add Media, and Upload Files to add it.

Click Insert into post from the Add Media screen to create a link to the file. The link text will just be the filename, but you can change it to what you want.

If you’re providing the same content in multiple file formats, repeat for the other formats.

Remember too, you can use an image as a link — such as the image of a book cover. Get the URL of the e-book file onto the clipboard (you can copy it from the file information in the media library). Insert a book cover image, click it, use the pencil icon to edit the image options, and paste the URL of the file as the Custom URL of the image link.

File Attachment in the Block Editor

Create the post or page where you’d like to attach the download, and add your pictures and text. At the point where you want someone to click to download, add a new “File” block.

Adding a File block to a page

If the e-book file is already in the media library, select it, else click Upload and upload it..

Click Upload to select file.

The “File” block by default shows the filename as a link, and a Download button. If you have multiple files to add – say, same content in different file formats – you can just change the link text to show which is which.

Copying URL from File block toolbar

Or, if you want to provide the same content in multiple file formats and would like something a bit snazzier, use the Buttons (note the plural) block. This inserts a row of buttons whose appearance you can control. You give each a URL, which is the URL of the file you want the button to download. You can copy the URL with the Copy URL button on the File block’s toolbar, or from the entry in the media library.

Then insert the Buttons block, add to it as many Buttons as you have files for download, and use the link control on the button’s toolbar to set the URL to that of the file you recently uploaded.

Using button block toolbar to set link path for ebook file

If you preview the page now, you can use these controls to download the file. This sample shows both the File block and the row of buttons — of course you don’t need them both.

User downloading EPUB file being asked what to do with it

Delete the File block now and just use the buttons – the file is in the library and will not be deleted.

What happens When Someone Tries to Download the File

The link in the widget, the link in the File block, the Download button in the File block, and the button bar, all work the same. However, what they do varies depending how the website visitor’s system is set up to deal with files of that type. Some people’s browsers will pop up a dialog asking whether to save the file or open it. Or, if the browser knows how to display a file of that type, it might just open in the browser.

If the browser displays a screen of garbage characters, the problem is not with your system; it’s with the server. Read E-book download garbage screen for the solution.

Free Sample for Subscribers?

What’s this I was saying about using the e-book download as a bonus for subscribers?

To do this, I’d put the download on a page as described above, but don’t link to the page from the menu or other pages. Use the “Search exclude” checkbox and the Yoast SEO “no robots” options to prevent people from finding the page unless you give them the link. Which you would do in the text of the “Welcome to my mailing list” email you send out automatically to new subscribers.

I wouldn’t worry about making it more secure than that. If someone wants to work hard they can probably find a different way to get to the page, but it would be more trouble than just subscribing, then unsubscribing once they had the file. This is just to prevent someone finding it by chance.

Leave a Reply

Your email address will not be published. Required fields are marked *