What an attachment page is
When you upload an image, WordPress stores the file (for example /wp-content/uploads/2024/05/tent.jpg) and, on older setups, also creates a page for it, such as /tent/ or /?attachment_id=123. That page usually holds the image, a title and little else.
For SEO that is a problem:
- Hundreds of near-empty pages compete for crawl attention with your real pages.
- Google may show the attachment page instead of the post that uses the image.
- Visitors who land there see one picture and leave.
Yoast's own help page calls these URLs not useful in almost every setup (Yoast, Media pages).
What changed in WordPress 6.4
WordPress 6.4 (November 2023) added an option called wp_attachment_pages_enabled (make.wordpress.org, October 16, 2023):
| Site | Value after 6.4 | What visitors get at an attachment URL |
|---|---|---|
| New install on 6.4 or later | 0 | Redirect to the file itself |
| Existing site upgraded to 6.4 | 1 | The old attachment page, unchanged |
So an upgrade did not fix older sites. If your site is older than 6.4, assume the pages are still there until you check.
How to check if your site still has them
- Open the Media Library, click any image and copy its "attachment page" link, or try
yoursite.com/?attachment_id=followed by a media ID. - If you land on a page with your theme's header and one image, the pages are on. If you land on the image file or the parent post, they are off.
- In Search Console, open Performance > Search results > Pages and filter page URLs for
attachmentor for slugs that match image names. Any clicks or impressions there mean Google has them indexed. - Check your sitemap index for an attachment or media sitemap. It should not be there.
How to turn them off
| Where | Path | Notes |
|---|---|---|
| Yoast SEO | Yoast SEO > Settings > Advanced > Media pages | Leave "Enable media pages" off. Off redirects each attachment URL to the file |
| Rank Math | Rank Math SEO > General Settings > Links > Redirect Attachments | Needs Advanced Mode. Redirects to the parent post; "Redirect Orphan Attachments" sends unattached files to a URL you choose, the homepage by default |
| No plugin | wp-admin/options.php, find wp_attachment_pages_enabled, set 0 | Or WP-CLI: wp option set wp_attachment_pages_enabled 0 |
| The SEO Framework | Free "Origin" extension in Extension Manager | Redirects attachment pages to the file |
Sources: Rank Math general settings, Yoast Media pages, make.wordpress.org.
Which target is better, the file or the parent post? Rank Math argues for the post, because it passes any links the attachment page earned to a real page. Yoast and WordPress core send visitors to the file. Both remove the thin page. If some attachment URLs have real backlinks, redirecting to the post keeps more value.
Cleaning up attachment URLs already in Google
Turning the setting on is most of the work. Then:
- Let Google recrawl. Redirected URLs drop out of the index as Google crawls them again. This can take weeks on a large site.
- Do not block them in robots.txt. Google has to crawl the old URL to see the redirect.
- Remove them from your sitemap. Your SEO plugin does this once media pages are off. Resubmit the sitemap in Search Console.
- Spot check a few with URL Inspection. The result should show the redirect target as the page Google picked.
- Use the Removals tool only for urgent cases. It hides a URL for about six months; it does not delete it (Google, Removals tool).
Your images stay in Google Images. Image search indexes the file URL, which is not affected.
When to keep attachment pages
A few sites use them on purpose: photo portfolios where each image has a long caption, or download libraries where each file page has a description. If that is you, keep them on, write real text on each, and treat them like any other page. Everyone else should turn them off.
How to use this with an AI assistant
Connect SEOmatic at https://seomatic.ai/mcp and ask: "Use gsc_performance top_pages for mysite.com over the last 90 days and list any URLs that look like WordPress attachment pages (image-name slugs or ?attachment_id=). Then check five of them with gsc_indexing inspect." This needs a free SEOmatic sign-in; the plugin setting itself stays a manual change.
More from the WordPress SEO checklist
- The checklistWordPress SEO Checklist (2026): 70 Settings and Fixes, With the Exact Admin Path
- GuideWordPress robots.txt: What It Should Say and How to Edit It
- GuideRank Math vs Yoast in 2026: An Honest Comparison
- GuideBest WordPress SEO Plugin in 2026: Yoast, Rank Math, AIOSEO, SEOPress or The SEO Framework
- GuideShould You Noindex Tag and Category Pages in WordPress?
- Guide"Discourage Search Engines from Indexing This Site": What It Does and How to Recover


