Canonical Attachments

plugin banner

This plugin allows a user to add an http canonical header for wordpress media files. The primary use would be to replace .pdf files in search results with the url of the attached (canonicalized) blog post. This allows you to track visitors that would otherwise have gone directly to the pdf file vs. your website post page, and further consolidates page authority to the blog post vs. the media attachments.

More detailed information is in the readme file, I just wasn't sure if this was supposed to be unique from the description provided there.

Author:Jake Bohall -- @hivedigital, @jblifestyles (profile at wordpress.org)
WordPress version required:4.5.1
WordPress version tested:5.6.13
Plugin version:1.7
Added to WordPress repository:19-01-2017
Last updated:30-12-2020
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:100
Rated by:2
Plugin URI:
Total downloads:5 649
Active installs:700+
plugin download
Click to start download

This plugin was developed to allow canonical tags as response headers to be created via htaccess for attachment files such as pdfs and docs.

The plugin:

  • Generates an htaccess file to manage the wp-content/uploads directory where these files are being uploaded
  • Updates the htaccess file with canonical tags which are delivered via a header when the attachment is called
  • Creates a dashboard where you can easily filter and find attachments without canonicals or that are not attached to a post.
  • Creates a dashboard where you can easily attach a file to its parent post (one at a time or in bulk) or manually add/remove a canonical tag for a file
  • Allows you to add a canonical url from the media file in the library or when you upload
  • Creates a dashboard to edit the .htacess file directly for the uploads directory in case there are additional files in the directory that were uploaded outside of wordpress (e.g. during a site migration)

The challenge: Analytics software such as Google Analytics, cannot track a user that enters a website via a pdf file in Google search results. Files cannot have a standard canonical tag added in the <head> and instead the canonical tag has to be added via an http header when the file is requested from the server. In order to accomplish this, we need to have an htaccess file listening for a request to that file, and then sending the header.

Expected outcome: PDF files and other attachments will be replaced in search results with the post or page counterparts, and we will be able to measure the traffic to those pages and provide calls to action for downloading the file, submitting contact forms, etc. Note: Canonical tags do not force a search engine to index one url vs. another, but act as a guideline/request to the search engine. As long as the attachment content is similar to the canonical URL, you should have no problem encouraging the search engines to choose the correct version.

Future Features and Development

Based on the feedback, we hope to continue developing additional features to support user requests. Current future feature ideas include:

  • Automatic canonicalization of non-image files to attached post
  • Integration with non-apache servers
  • Canonical builder for non-wordpress media files
  • Option to bulk delete canonical associations and delete htaccess on uninstall

Screenshots
FAQ
ChangeLog