seo

Attachment pages in WordPress: check, switch off or redirect

Check whether Google indexed WordPress attachment pages in Search Console, then switch them off or redirect them, with a test of one URL after each step.

You typed a few words into Google, or opened the Pages report in Search Console, and saw a result titled after a file name. It leads to a bare page with one picture on it. You did not build that page, and now you wonder whether files are leaking, content is duplicated or rankings are slipping.

Those are WordPress attachment pages. WordPress can generate one for every file you upload, separate from the file itself, with little more than the image, your theme layout and a title taken from the file.

You can check a single URL in about a minute, and the fix for a simple case is one setting. The order is look, confirm, switch off, recheck.

Key Takeaways

Test one URL first

Open a suspected link in a private browser window and see whether it is a page with a theme around the image or the bare image file.

Core changed in 6.4

WordPress 6.4, released November 7, 2023, turned attachment pages off for new installations; sites upgraded to 6.4 kept their previous behavior.

Search Console is the record

A site: search gives samples; Indexing, Pages and URL Inspection show what Google did with a URL.

Pick the response that fits

Switch the pages off where they serve no purpose, redirect to the media file, or use noindex where a page must stay reachable.

Switching off keeps your images

The Media Library files stay in place, and robots.txt cannot remove an indexed page.

How do you tell an attachment page from the image file?

Start with one URL you do not recognize. Copy it from the Google result or from Search Console and paste it into a private browser window, so your login does not change what you see. An attachment page loads inside your site layout, with your header, footer and a title that often matches the file name. The image file itself loads as a bare picture with nothing around it.

That one look tells you which problem you have. According to WordPress.org's description of the 6.4 change, the attachment page and the file are separate URLs, and the page may hold little more than the image, the title and some metadata.

If the URL turns out to be the plain file, no attachment-page fix is needed. Those files can show up in Google Images, which is a different matter from a page in the web results.

A closed laptop beside a small wooden frame and a pencil on a plain desk, set up for a quiet look at one unfamiliar link.
One URL in a private window shows whether you have a page or just a file.

How can you check whether Google indexed your attachment pages?

Use a search for samples, then use Search Console for the real status. In Google, try `site:yourdomain.com attachment`, then `site:yourdomain.com /image/`, or search a known image slug. The `site:` operator shows examples only, never a full inventory, so treat the results as a way to spot what to inspect.

Then open your property in Search Console and go to Indexing, then Pages. Google's Page indexing help explains each group in that report. Look at Indexed, Page indexed without content, Crawled - currently not indexed, Discovered - currently not indexed and Page with redirect. Paste one suspected URL into URL Inspection to see whether Google treats it as indexed, redirected, canonicalized or blocked.

Search Console does not promise a complete list of every URL Google knows about, so a short list there is a sample too.

What each check tells you
CheckWhereWhat it tells you
Private browser windowYour browserWhether the URL is a page or the bare file
site: searchGoogleA few examples of what is showing
Indexing, then PagesSearch ConsoleWhich groups the URL falls into
URL InspectionSearch ConsoleWhether Google sees that URL as indexed, redirected, canonicalized or blocked
CheckPrivate browser window
WhereYour browser
What it tells youWhether the URL is a page or the bare file
Checksite: search
WhereGoogle
What it tells youA few examples of what is showing
CheckIndexing, then Pages
WhereSearch Console
What it tells youWhich groups the URL falls into
CheckURL Inspection
WhereSearch Console
What it tells youWhether Google sees that URL as indexed, redirected, canonicalized or blocked

Why does WordPress make a page for every image?

For years, uploading a file to the Media Library gave it its own page by default. WordPress 6.4, released November 7, 2023, changed that for new sites. The WordPress 6.4 release notes say attachment pages are disabled on new installations.

The mechanism is an option named `wp_attachment_pages_enabled`. New sites have it set to 0, and requests for an attachment page redirect to the file. Sites that were upgraded to 6.4 kept the previous behavior, with the option set to 1, as the WordPress developer news for November 2023 describes.

So, an older site can still have these pages today, and an update alone will not have changed that.

How do you switch attachment pages off in Yoast SEO?

If your site runs Yoast SEO, the setting sits in the plugin. Yoast documents the path on its help page for image attachment URLs, and the steps run like this.

  1. Log in to WordPress.
  2. Open Yoast SEO, then Settings.
  3. Open Advanced, then Media pages.
  4. Turn Enable media pages off.
  5. Save the setting.
  6. Open an old attachment-page URL in a private browser window.
  7. Confirm it now goes to the media file.

Current Yoast redirects the attachment URL to the media file. Older versions could send visitors to the parent post or page, and Yoast changed that because one image can be attached in more than one place. If you use a different SEO plugin, find its media or attachment setting in your installed version and run the same private-window test.

A single unlit desk lamp beside a closed notebook and a coil of string on a worn wooden table.
One saved setting, then one test in a private window.

Leave the hidden `wp-admin/options.php` screen alone unless you know what you are changing. It exposes the core option, but it is an administrative screen and not a normal settings page.

Should you switch the pages off, redirect them, or use noindex?

Each response fits a different situation. Switching off fits when your site has no reason to show a page for an uploaded file, which fits a business site with no designed media pages. A redirect sends a visitor who lands on the old URL to a clear replacement, and Google says that a moved page should return a 3XX redirect to its new location.

A noindex rule keeps the URL reachable while keeping it out of Google Search. Use it only where an attachment page has a deliberate purpose, such as a designed media page you want visitors to reach.

Which response fits
Your situationResponseWhat happens
Pages serve no purposeSwitch media pages offThe old URL goes to the media file
Old URLs still circulateRedirect to the file or a better pageVisitors reach a working destination
A page must stay reachableNoindexThe URL stays open and drops out of search after Google recrawls it
Your situationPages serve no purpose
ResponseSwitch media pages off
What happensThe old URL goes to the media file
Your situationOld URLs still circulate
ResponseRedirect to the file or a better page
What happensVisitors reach a working destination
Your situationA page must stay reachable
ResponseNoindex
What happensThe URL stays open and drops out of search after Google recrawls it

Do not redirect every image page to your home page by habit. A redirect works best when the destination matches what the old URL showed.

Why does robots.txt not remove an indexed attachment page?

Blocking a URL in robots.txt stops Google from crawling it. It does not remove a page Google already knows about, and it can hide a noindex tag, because Google has to crawl a page to see that tag. Google's guidance on blocking indexing says that a noindex directive works only when the page is crawlable.

If you have blocked the pages in robots.txt and still want noindex to work, remove the block, let Google crawl the page and keep the noindex or redirect rule in place. Remember too that noindex is not instant. It takes effect after Google recrawls the URL.

Two empty envelopes and a pencil resting on a clean wooden tray beside a sealed cardboard box.
A blocked page cannot show Google its noindex tag.

Do attachment pages hurt your rankings?

An attachment page is not a penalty on its own. What it can be is an unneeded URL that shows up in search with almost nothing on it. Google says you should not expect every URL on your site to be indexed, only the canonical pages, and it suggests cutting back duplicate or minor URLs when they get in the way of crawling priorities, as its Search Console Help explains.

For an ordinary business site, a few indexed attachment pages are a tidy-up job and not an emergency. A large number of thin pages, on the other hand, can crowd your results and clutter your reports.

A page marked Crawled - currently not indexed is not necessarily broken either. It tells you what Google decided, which is the cue to decide whether the URL should exist.

What should you check after you make the change?

Confirm the image still displays on the pages that use it. Switching attachment pages off does not delete anything from the Media Library, so your files stay in place. Open two or three posts or pages with images and look.

Next, test a few old attachment URLs in a private window and note where each one goes. Check that nothing loops or sends visitors to an unrelated page. If your own posts or menus link to attachment URLs, change those links to the image file or to the post that fits.

Then check your sitemap for attachment URLs and wait for Google to recrawl. Look at Indexing, Pages in Search Console again once Google has recrawled, and re-inspect one of the old URLs to see its new status.

A stack of blank index cards, a small metal ruler and a closed notebook lined up on a pale desk.
Test one old URL, then return to Search Console after Google recrawls.

When do you need someone to do this for you?

An owner can often check and fix a simple case alone, with one setting and one test. A paid rebuild is not needed for that.

Help starts to make sense when the site has thousands of old URLs, SEO and redirect rules that conflict, attachment links on important pages, a CDN or server that changes responses, or several domains. In those cases the setting is only one part of the picture, and each old URL needs a clear response across redirects, internal links, sitemaps, caches and plugins.

If your site falls into that group, a targeted check and a safe cleanup is the right size of job. Thin image URLs overlap with duplicate content on a small business website, with the question of whether to update, merge or delete old pages, and with a website quietly breaking its own SEO, and each of those has its own post.

Do you know your attachment pages?

Pick an answer to begin.

1. What is the first thing to do with a suspicious image URL?

2. What changed in WordPress 6.4, released November 7, 2023?

3. Can robots.txt remove an attachment page that Google already indexed?

Frequently Asked Questions About WordPress Attachment Pages

What is a WordPress attachment page?

It is a separate web page WordPress generates for an uploaded image or other media file. It is not the same URL as the file.

Does WordPress 6.4 disable attachment pages?

For new installations, yes. Existing sites upgraded to 6.4 keep their previous behavior until you change it.

How can I tell if Google indexed my attachment pages?

Use a site: search for examples, then check Indexing, Pages and URL Inspection in Search Console for the real status of each URL.

Will switching them off delete my images?

No. It changes how WordPress treats the generated page. Your Media Library files stay in place.

Should I use noindex or a redirect?

Use a redirect when a clear replacement exists, such as the media file. Use noindex when a page must stay reachable but should stay out of search results.

Does robots.txt remove attachment pages from Google?

No. Blocking crawling can stop Google from seeing a noindex tag, so remove the block if you rely on noindex.

Wrapping Up

Open one suspected URL in a private window to see whether it is an attachment page or the file. Confirm its status in Search Console, then pick the response that fits: switch the pages off, redirect to the media file, or use noindex where a page must stay reachable. Your images stay in the Media Library either way, and robots.txt is not the tool for removing a page Google already has.

Once the setting is saved and a few old URLs are tested, Google shows the new state as it recrawls. Your reports get shorter, and visitors reach the image or the right post and not a bare page.

If your site has thousands of old URLs or rules that fight each other, Web Leveling can run a targeted check and a safe cleanup through our website maintenance work. The sites we build have no attachment pages. We work with small and medium businesses across the country and overseas. Contact us about a WordPress cleanup and tell us what you are seeing in Search Console.

Terms

Attachment page words in this post

Tap a term to see what it means.

Attachment page. A page WordPress generates for an uploaded media file, separate from the file URL.

Media Library. The WordPress area where uploaded images and other files are stored.

Noindex. A directive that keeps a page out of Google Search after Google recrawls it.

Redirect. A response that sends a visitor from one URL to another.

URL Inspection. A Search Console tool that shows how Google sees one specific URL.

Canonical page. The version of a page Google treats as the main one to index.