I have a static site in Gatsby. I'm using an <a>
tag to link to a pdf file to download, shortened version below:
import file from '../files/file.pdf';
<a
className='hover:underline hover:text-black'
href={file}
download
>
This works fine, except that Google is now indexing the content of that file. I would like for it not to. The only things I've found suggest that you can add a noindex
to the meta tags for a page you don't want indexed, which makes sense - but there is no page for the file, it's just the file itself. I could also conceivably add a nofollow
to the link itself, but I'm not sure how to do that in Gatsby.
What's the best way to remove that "page" from search indexes? Thanks!
You can add a nofollow
attribute like this:
<a
className='hover:underline hover:text-black'
rel="nofollow"
href={file}
download
>
That will tell the Google Bot not to follow that link.
Another option would be to list the URL in your robots.txt
.