Currently Available: Need a skilled Software Developer for your next project?
Categories
WordPress

How Yoast SEO Handles Attachment Pages in Sitemaps

In WordPress, an uploaded image has a file URL and may also have an attachment page, a web page WordPress creates for that media item. The file URL serves the image, while the attachment-page URL serves the page. A sitemap lists URLs for search engines. Because these are different URLs, finding an image in a sitemap does not prove that its attachment page is listed.

Yoast SEO uses its Media pages setting to control attachment pages. Whether a URL appears in a sitemap depends on whether Yoast considers it eligible for indexing, meaning allowed to appear in search results. To check an attachment page, inspect the sitemap Yoast generates, then check whether the page is enabled, allowed to be indexed, and served at its own URL.

Media pages control whether attachment URLs serve pages

In Yoast’s current settings, find the control at Yoast SEO → Settings → Advanced → Media pages. Yoast says media pages are disabled by default. When they are disabled, Yoast redirects attachment URLs to the media file. When they are enabled, the attachment URL serves a page. Yoast also provides settings for how that page appears in search results and for its SEO details. See Yoast’s Media pages settings.

This setting answers whether a visitor reaches an attachment page at that URL. It does not, by itself, establish that Yoast will list the URL in a sitemap. A page must also meet Yoast’s sitemap eligibility rules.

Yoast lists eligible URLs, not every media file

Yoast’s sitemap documentation says that content marked noindex is left out of the sitemap. The “Noindex” instruction tells search engines to leave a page out of search results. Yoast also excludes pages with a manually set canonical URL that differs from the default. A canonical URL identifies the version of a page that search engines should treat as preferred. Private or password-protected pages are also among the exclusions in Yoast’s sitemap specification.

Yoast’s settings for whether a post type appears in search results also affect sitemap inclusion: content types removed from search results are removed from the sitemap. The sitemap settings documentation describes these general rules, but does not guarantee that every installation with Media pages enabled will show a separately named attachment sitemap. Check the live sitemap index and the specific attachment URL for your installed version.

An image listed as part of a post’s sitemap entry is a separate matter. Yoast can include image information with a post or page entry; that does not mean the image’s attachment-page URL appears as its own entry. Yoast’s explanation of images in sitemaps describes that image data.

Check the sitemap and the attachment URL

Start with Yoast’s sitemap index at https://example.com/sitemap_index.xml, replacing example.com with your site’s domain. The index links to child sitemaps, which are separate sitemap files containing URL entries. Yoast cautions that /sitemap.xml may come from WordPress, another plugin, or a physical file rather than Yoast. Its XML sitemap documentation describes the index path and how Yoast’s sitemap works.

Open the relevant child sitemap, if one appears, and search for the exact attachment-page URL. Do not search only for the image file URL; it may have a different path. If you do not see an attachment-related child sitemap, do not assume that an image entry elsewhere represents the attachment page.

Then open the attachment-page URL in a browser. If it redirects to the image file, Yoast is not serving a page at that URL under the current Media pages setting. If it loads a page, check its indexability and canonical in Yoast. Also confirm that it is not password-protected. The sitemap index itself may be turned off under Yoast SEO → Settings → Site features → Technical SEO.

Check settings and caching when the output surprises you

If the page loads but is absent from the sitemap, first confirm that its Media pages settings and indexability allow it to appear. Next, confirm that you are checking /sitemap_index.xml and the child sitemap it links to, rather than a sitemap generated by another source. A custom plugin or code that changes sitemap output can also affect the result; Yoast documents sitemap customization options.

If you recently changed a setting or updated content, a cache may keep serving an older sitemap, making it appear unchanged. A WordPress plugin, theme, or server-level cache may store and serve an older response. Yoast recommends checking those caches when a sitemap does not update; see its sitemap troubleshooting guidance. After clearing or excluding the sitemap from caching, reload the index and child sitemap and search again for the exact attachment-page URL.

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *