Wow! I was so glad I found this post from Jim Julian this week which pointed me in the right direction to fix my WordPress Media Attachment Page 404 Error. That little nugget pointed me in a whole new direction, where I picked up all kinds of tidbits to fix my site. In this article, I share my findings with my attachment page 404 error, and provide a brief overview of what to do with attachment pages for the best SEO. Handling attachment pages is particularly important for photographers who have many images on their websites.
My Attachment Page 404 Error…
In Google Search Console, I was getting 404 error’s that appeared to point to my image files. It took me a bit of searching to figure out these were the attachment pages WordPress creates when adding media to the WordPress Media Library. Every media file has an attachment page or specifically a post. In fact, WordPress creates a post record in its database for everything, like a row in a spreadsheet or a line on a list. There are different types: regular posts, pages, attachments, and custom types created with themes or plugins such as gallery, collection, quick gallery, or portfolio to name a few. Please don’t get confused when I use the post and page terms interchangeably in this article. I tend to use which ever sounds the best to me at the time.
What do these attachment pages look like? Pretty boring if you ask me. Your theme templates usually control how the attachment pages look. Here is the attachment page on my main website:
The attachment page is pretty plain, but some folks add formatting and use it to create their own gallery. That sounds pretty cool, but I just settle for the gallery plugins and themes out there to give me my gallery functionality. If you want to learn more about attachment pages and customizing them, check out this post by Daniel Pataki which I found very informative.
Attaching to a Post or Page
So, when you add a media file to a post, that attachment usually becomes attached to that page or post. The attachment page can only be attached to a single parent post or page, and once attached there is no way to unattach from within WordPress without a plugin.
If the parent post is deleted, the attachment page does not become unattached. It gets lost like in Jim’s example and creates the 404 errors when Google crawls your site; or in my case, if the post is private or a draft, the attachment page 404 error will show.
I use WP/LR Sync to upload my photos from Lightroom to my websites. This plugin has the option to create a collection or quick gallery post associated with my published collections from Lightroom. I used this functionality some times, but it never seemed to work with my theme. I found the posts were being created, but apparently, the parent post was listed as private in the WordPress database.
The standard WordPress Media library will show you which media is still unattached, and allow you to attach it within the media library without opening an existing post/page. But that is about it. To see more information you need something to show more of the WordPress database. One option is the Media Library Assistant which Jim used in his search for a solution. I have found this plugin to be very helpful so far. There is a lot more to explore with this plugin, but for now it is helping me solve my attachment problems. I can see the parent post ID for each media file and correct errors without having to delete and re-upload the media. So now I can fix my attachment page 404 errors, but I also learned more in this process.
Attachment Pages and SEO
As shown above, attachment pages are plain with just the image or video showing, nothing else. Google is a robot, and robots cannot see and interpret images or video. The bots need words. Yoast recommends a minimum of 300 words in a post. An acquaintance from Google recommends 1000-1500 words, especially for your home page. You can and should add your info to the photo like the file name, title, and alt-text, but this is not enough. Attachment pages will fall into the Google category of “thin content” which can impact your website ranking.
But wait, there’s more. If you embed your image in a post, the associated attachment page will have duplicate content which is also a big no-no to Google’s bots. Using the Yoast SEO plugin you can decide to not create a sitemap for the attachment pages, but those pages will eventually be found by the Google bots. There is another option in Yoast. You can redirect any bots or others that find your images back to your parent post where the image was attached. This is the option I use.
So what about the images in your media library that you have not used yet and have not attached to a page? Those attachment pages have no place to be redirected. So you should minimize unused media on your website. Keep those images in Lightroom or on your desktop until you have a specific use for them on your website.
As mentioned earlier, you should already be adding a descriptive file name and title, and a good description for the alt-text to tell the Google bot what your image is about. Without a title, WordPress will use the file name as the title, and without the alt-text the google bot will be very disappointed with just _DCS3274.jpg to describe the image. The Google bots will not have a reason to show your images in a search because there isn’t any text to match to a specific search request. Your images will be ignored, and and not show up in the SEO rankings.
Conclusion
So here you go, you can fix your attachment page 404 error with the Media Library Assistant, and improve your overall SEO ranking with Yoast SEO. Here are the steps to improve and protect your SEO ranking for your images.
– Add a descriptive file name, title, and alt-text to each image file, and try not to duplicate your text between images.
– Minimize or eliminate unused images on your website which create thin content attachment pages.
– Attach your images to a regular page or post that has at least 300 words, and preferably 1000-1500.
– Set up your Yoast SEO settings to redirect the media attachment page back to the parent post.
Was this helpful? Is there something you would like to share to help others? Let me know what your experience has been in the comments below.
[learn_more caption=”My website setup”]
- WordPress 4.7
- Permalinks set to %postname%
- Yoast SEO set to redirect attachment pages to the parent post
- Yoast set to create the attachment sitemap
- Division Theme
- WP/LR Sync
- Media Library Assistant to check and correct attachment pages
[/learn_more]
This was a great article and explained perfectly what the issue was. Thank you!