You may be running an online business selling eBooks and want to prevent people from finding the file using search engines. Or you may have sensitive information stored in those PDF documents that shouldn’t be publicly available.
In that case, you can easily hide (noindex) your PDF files to maintain privacy and ensure that only the intended users can access these documents.
In this article, we will show you how to easily hide (noindex) PDF files in WordPress.
Why Hide (Noindex) Your PDF Files in WordPress?
PDFs are one of the most popular file formats, and uploading them to your WordPress website has many benefits.
PDFs are often used to build an email list. A lot of people convert long tutorials on their blogs into PDFs and then offer them as exclusive content on their websites.
These 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 are using PDFs on your website or WooCommerce store in a similar way, then it is best to hide your files from search engines and crawlers.
You do not want people to find your PDF files through search results where users can access them without providing you with their email addresses or payments.
You might also have PDFs containing sensitive data that shouldn’t be searchable by the public. Hiding those files using noindex is essential for protection and data security.
That being said, let’s show you how you can easily hide your PDF files from search engines. We will cover different methods, and you can use the quick links below to jump to the one you want to use:
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 All In One SEO.
It is the best WordPress SEO plugin on the market that allows you to easily optimize your website for search engines and social media platforms.
This plugin also allows you to edit your robots.txt file, which gives bots instructions about your site.
For this tutorial, you will be adding a bit of code that will tell them to ignore your PDFs.
First, you need to install and activate the AIOSEO plugin. For further instructions, see our beginner’s guide on how to install a WordPress plugin.
Next, you will have 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 the All in One SEO » Tools page in the WordPress dashboard.
From here, switch to the ‘Robots.txt Editor’ tab and toggle the ‘Enable Custom Robots.txt’ option.
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.
After that, 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.
Your robots.txt file will now tell Google Search and other platforms 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 can simply type the name of that PDF in the ‘Directory Path’ field.
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 PDFs 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. Keep in mind that this method is a bit advanced and may be difficult to apply for beginners.
First, simply connect to your website using any FTP client or 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.
Upon locating it, right-click and open the ‘View/Edit’ option.
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
.
If you are using an 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 are using the Ngnix server, then add the following code:
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 the .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 a password or email address to download PDFs, or even collect payments, then you will need one of the following tools:
MemberPress is the best WordPress membership plugin on the market. In fact, we used it to power our free video membership site and loved it.
For more details, check out our full MemberPress review.
The great thing about MemberPress is that 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.
MemberPress also lets you create and sell online courses, and often, website owners offer premium PDF companion guides with their courses.
This method will ensure that your PDF files are fully password protected, and no one can access them unless they enter a password and log in.
Easy Digital Downloads is a popular WordPress eCommerce plugin for selling digital products such as PDF files, eBooks, and more. Our partner brands use this tool on their websites to sell software and plugins.
So, we know it’s user-friendly and reliable. For more details, see our Easy Digital Downloads review.
It comes with maximum file protection features for PDF files, so you can store them 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 and restrict PDF access by user subscription level.
OptinMonster is the best lead generation plugin for WordPress. It helps you get more email subscribers and sales from your website visitors.
At WPBeginner, we even use it for all our popups, banners, and deals. For more details, see our full OptinMonster review.
A lot of website owners use OptinMonster to require users 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 top picks for the best WordPress SEO links plugins 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.
Mrteesurez
This is great. No one will allow paid PDFs to be accessed by a search engine unless there are free. I run an ebook store so this guide will be of help for me. But my question is, if I block all the PDFs, will their titles and details still available for crawling by search engines for visibility ?
WPBeginner Support
Normally you would use the product page that you are selling the PDF to give search engines that information.
Admin
Mrteesurez
Meaning I will need to create a product page for each book so as to make it be visible to search engine, right ?.
I ma using Woocommerce, I think it create post type product, can’t that be used instead of creating sales page/landing page ?
WPBeginner Support
For WooCommerce, the product’s page would be the sales page normally.
Mrteesurez
Ok, I now understand what you are really taking about. Woocomerce product will be the sales page, Applying Noindex will only affects the PDF document itself and this will not affect it’s woocomerce page(product page) from indexing.
Thanks for your reply, I like your support.
Jiří Vaněk
Thank you for the perfect tutorial. I have AIO SEO, but I didn’t know that I can edit various files in robots.txt in this way. I assume that I can use the same method to hide other file extensions such as .docx etc.?
WPBeginner Comments
Yes, other file types can be hidden in a similar manner.
Jiří Vaněk
Thank you for the response. I have several types of files on my website, mainly text files, that I need to hide this way. Thanks for the reassurance; I will use your guide for this. It’s simple and effective, which is important to me.
Kiran
In .htaccess file
Header set X-Robots-Tag “noindex, nofollow”
is used. Apache server. But when I test, the .pdf URL appears indexable.
Tried all methods. Still the PDF file is getting indexed in the search engines.
I read about this code in more than 20 blogposts and forums online. Everyone has told about this option regarding X-Robots-Tag, but no one has told that it is working.
Can you tell?
WPBeginner Support
If you have not done so already, please reach out to your hosting provider to ensure there are not rules set on their server that may be conflicting or preventing the change from being accepted for a likely cause.
Admin