How to Easily Hide (Noindex) PDF Files in WordPress

Do you want to hide your PDF files from search engines?

You might be running an online business selling ebooks and want to prevent people from finding the file using search engines. Or you might have sensitive information stored in those PDF documents that shouldn’t be publicly available.

In this article, we will show you how to hide (noindex) PDF files in WordPress.

How to Hide (Noindex) PDF Files in WordPress

Why Should You Hide (Noindex) Your PDF Files

PDFs are one of the most popular file formats, and there are many benefits of uploading them on your WordPress website.

PDFs are often used to build an email list. A lot of people convert long tutorials on their blog into PDFs, and then offer them as exclusive content on their website.

PDF files are also used to offer exclusive members-only premium content for paying subscribers as part of an online course or membership site.

If you’re using PDFs on your website in a similar way, then it is best that you hide your PDF files from search engines.

You do not want people to find your PDF files through search results where users would be able to access your PDFs without providing you with their email addresses or payments.

You might also have files containing sensitive data that shouldn’t be searchable by the public. Hiding those PDFs using noindex is essential for protection and data security.

With that being said, let’s show you how you can easily hide your PDF files from search engines.

Method 1. How to Hide (Noindex) Your PDF Files Using AIOSEO (Recommended)

The best way to hide your PDF files from search engines is by using the AIOSEO plugin.

All in One SEO (AIOSEO) is the best WordPress SEO plugin that allows you to easily optimize your WordPress website for search engines and social media platforms.

This plugin also allows you to easily edit your Robots.txt file, which gives bots instructions about your site. You will be adding a bit of code that will tell them to ignore your PDFs.

The first thing you need to do is install and activate AIOSEO. For further instructions, you can see our guide on how to install a WordPress plugin.

Next, you will need to set up AIOSEO for your site. If you need help, then you can follow our step-by-step guide on how to set up All in One SEO in WordPress correctly.

Once the plugin is activated, head over to All in One SEO » Tools in the WordPress dashboard.

Now that you’re on the ‘Tools’ page, head over to the ‘Robots.txt Editor’ section and click the toggle present beside ‘Enable Custom Robots.txt.’

Toggle the Enable Custom Robots.txt button

After that, scroll down to where it says ‘User Agent’ and simply add an asterisk (*) to apply the rule to all bots that crawl your site.

Then, select the ‘Disallow’ option in the ‘Rule’ section. Doing this will block all of the user agents from accessing the PDF files. Now, all you have to do is enter a directory path. Simply add /pdf/ in the ‘Directory Path’ field.

Note: If you have saved your PDF directory folder under any other name, then you will have to write that exact PDF directory name in the ‘Directory Path’ field.

Fill in the Rule Builder fields

Next, just scroll down and click on the ‘Save Changes’ button.

Once that’s done, you’ll be able to view your rules in the ‘Robots.txt Preview’ section of the page.

Robots.txt Preview box

Your robots.txt file will now tell search engines to ignore all the PDF files that are present in your PDF directory folder.

If you only want to hide individual PDF files, then you will need to simply type the name of that PDF in the ‘Directory Path’ field.

An example for a specific PDF you want to hide

For example, as you can see in the image above, entering example-pdf.pdf will prevent that single PDF file from being indexed without affecting others.

You can also add a rule like Disallow: /*.pdf$ to hide all PDF from search engines, but this will only work when User-agent is set to Googlebot. Not all search engines respect a broad rule like that.

Method 2. How to Hide (Noindex) Your PDF Files Using X-Robots-tag

If for some reason the previous method doesn’t work, then you can use the X-Robots-tag to hide your PDF files.

In this method, you will need to manually edit your WordPress site’s .htaccess file and add X-Robots-tag to it.

First, simply connect to your website using any FTP client or by using the file manager app on your WordPress hosting control panel.

Next, locate your .htaccess file which will be in the same folder as your /wp-content/ and /wp-admin/ folders.

If you cannot find the .htaccess file, then you can follow our tutorial on why you can’t find the .htaccess file to make it visible.

For this tutorial, we will be using FileZilla as an FTP client. Once connected to your site, you will find your .htaccess file in the ‘Remote Site’ section in the right-hand column.

Once you locate the .htaccess file, right-click and open the ‘View/Edit’ option.

view-htaccess-file

This will open the file in a text editor. If you are using Notepad, here is how it may look after you’ve added the X-Robots-tag.

X-robots-tag in Notepad

If you’re using Apache server, then simply add the following X-Robots-tag in the .htaccess file.

<Files ~ ".pdf$">
Header set X-Robots-Tag "noindex, nofollow"
</Files>

If you’re using Ngnix server, then add the following:

location ~* .pdf$ 
{
add_header X-Robots-Tag "noindex, nofollow";
}

Once you’ve added the X-robots-tag, simply save your file. This will now mark all .PDF files as noindex/nofollow, which means you’ve succeeded in hiding your PDF files from search engines!

Bonus: How to Protect PDF File Download in WordPress (3 Ways)

The above two methods cover how to hide PDF files from search engines, but if you want to further restrict PDF downloads to members only, require password or email address to download PDF, or even collect payments, then you will need one of following tools:

1. MemberPress

MemberPress is the best WordPress membership plugin in the market. It allows you to restrict PDF file access to registered-members only. You can even sell access to PDF files based on different subscription levels the user have.

MemberPress also lets you create and sell online courses and often website owners offer premium PDF companion guides with their courses.

Basically, this method will ensure that your PDF files are fully protected, and no one will be able to access your PDF file, unless they enter a password and login.

2. Easy Digital Downloads

Easy Digital Downloads is a popular WordPress eCommerce plugin that helps you sell digital products like PDF files, eBooks, and more.

It comes with maximum file protection features for PDF files, so you can store it in a private cloud, generate unique access links for each member, track download activity, limit the number of times a specific file can be downloaded, and more.

You can accept payments via credit card, PayPal, and others, so you can restrict PDF access by user’s subscription level.

3. OptinMonster

OptinMonster is the best lead generation plugin for WordPress. It helps you get more email subscribers and sales from your website visitors.

A lot of website owners use OptinMonster to require user to enter an email address before giving them access to their PDF files.

This process is called delivering a lead magnet or content upgrade. Once the user enters their email address in OptinMonster, they’re added as a subscriber in your email marketing service or CRM.

After that, they’ll get access to the PDF file in a personalized welcome email.

We hope this article helped you learn how to hide (noindex) your PDF files from search engines. You may also want to see our guide on how to build an email list in WordPress and check out our article on how to stop search engines from crawling a WordPress site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Easily Hide (Noindex) PDF Files in WordPress first appeared on WPBeginner.

Leave a Reply

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

Leave a comment

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