Headless WordPress sitemap lists the backend domain
Trace backend URLs in a headless WordPress sitemap, map CMS records to public frontend routes, and verify canonical pages without changing admin access.
By Crawlito · 5 min read
In short
- A CMS permalink is not automatically the public frontend route in a headless site.
- WordPress core's post sitemap uses get_permalink for its loc entries.
- Map and verify frontend URLs before replacing backend hosts in bulk.
On this page
- Identify which system owns the public sitemap
- Map CMS records to public routes
- Check canonical URLs and links alongside the sitemap
- Repair the generator without breaking the CMS
- Validate the generated XML and destinations
- Decide what to do with old backend URLs
- Verify the next publication, not only old records
- Frequently asked questions
If a headless WordPress sitemap lists the CMS domain instead of the public website, trace how it builds each post permalink. The CMS and frontend may use different hosts and route patterns. Generate sitemap entries from the actual public route mapping, then verify that each entry reaches the intended article and agrees with its canonical URL.
A simple hostname replacement may work for one page and fail for archives, translated posts, or custom content types. Establish the mapping before making a site-wide change.
Identify which system owns the public sitemap
Start with the sitemap URL submitted to search systems and the sitemap referenced by the public robots file. Follow any sitemap index to its child files.
Determine whether the output comes from WordPress core, an SEO plugin, the frontend build, or a separate service. These systems can coexist, so the file name alone may not identify the owner.
The WordPress core post sitemap implementation uses get_permalink when building a post's loc entry. That explains a possible path from CMS permalink configuration to sitemap output; plugins and custom implementations may behave differently.
Save an affected entry and open it as a logged-out visitor. It may show a backend theme, redirect, require a login, or fail completely. Each result tells you something about the published mapping.
The WordPress sitemap ownership guide helps identify the generator before changing its behavior. Fix the system that actually publishes the file consumed by crawlers.
Map CMS records to public routes
Choose examples from each relevant content type. Include a normal post, a page, a custom post type, a nested route, and a localized version if the site uses them.
Build a mapping table from stable CMS identifiers to frontend destinations:
| CMS record | CMS permalink | Intended public route |
|---|---|---|
| Guide record | cms.example.com/setup/ | www.example.com/guides/setup |
| Support record | cms.example.com/help-import/ | www.example.com/help/import |
| Localized record | cms.example.com/ar/setup/ | www.example.com/ar/guides/setup |
These are hypothetical examples. Your mapping should come from the frontend router and published content, not a guessed naming convention.
WordPress documents get_permalink as retrieving a post's permalink. In a headless architecture, your frontend may interpret the underlying content differently.
Do not use title matching as the permanent mapping key. Titles can change or repeat. Prefer the identifier or content relation already used by the frontend publishing process.
Check canonical URLs and links alongside the sitemap
Fetch a representative public article and inspect its canonical URL, internal links, and visible body. A correct sitemap cannot compensate for a page that still declares the backend host as canonical.
Also inspect navigation generated from CMS fields. Absolute links stored in rich text may continue pointing to the backend even after the sitemap generator is fixed.
The canonical URL guide explains the need for consistent URL signals. For this incident, the goal is not merely a matching hostname but the correct frontend resource.
Keep API endpoints separate from public article destinations. A JSON content endpoint is not a substitute for the human-readable page that should appear in discovery.
Check preview routes as well. A draft preview may intentionally use a different host or access token. Those URLs should not enter the public sitemap simply because they are available in the CMS response.
Record the chosen public URL as part of the content's published state so the sitemap, navigation, and metadata can use the same mapping.
Repair the generator without breaking the CMS
Choose where public URL generation belongs in your architecture. The frontend may generate the sitemap from published records, or a supported CMS integration may emit the frontend URLs.
Avoid changing the WordPress installation or home URL blindly. Those settings can affect more than sitemap entries, including administration and existing integrations. A route-mapping defect should not become an unrelated CMS migration.
If you use a filter or plugin setting, scope it to the intended public output and test all affected content types. If the frontend builds the sitemap, ensure it uses only published records and the same route logic as the pages.
Do not concatenate the frontend host with every CMS path unless you have proved that the paths match. Nested content, language prefixes, and custom routes often break that assumption.
Keep the previous sitemap artifact and mapping sample so you can compare the change. The repair should be reviewable as a set of intended destinations, not just a large text replacement.
Validate the generated XML and destinations
Download the published sitemap after the change and parse it. For each representative content type, fetch the listed URL and verify the intended title and body.
An illustrative extraction check is:
import xml.etree.ElementTree as ET
from urllib.parse import urlsplit
root = ET.parse("sitemap.xml").getroot()
for element in root.findall(".//{*}loc"):
url = element.text or ""
print(urlsplit(url).hostname, url)This shows hosts in the file; it does not validate every route or canonical relationship by itself. Review unexpected hosts, then test the actual destinations.
Check the sitemap index too. Its child-file URLs may still point to the backend even if the entries inside those files are correct.
Verify that the public robots file references the intended sitemap. Then update submitted sitemap locations where needed through the normal webmaster workflow.
The sitemap index guide helps ensure the corrected files are reachable from the index that crawlers actually discover.
Decide what to do with old backend URLs
If backend-rendered pages were previously public, identify whether they have a valid public equivalent. A deliberate redirect may be appropriate where the mapping is known, but do not redirect every CMS path to the frontend homepage.
Keep administration and API routes under their intended access rules. They are not article aliases and should not be included in a broad redirect pattern without understanding the application.
For unmatched old pages, decide the correct content lifecycle individually or by a well-defined category. A nonexistent article should not become an unrelated successful page.
Record the mapping used for any redirects and test it against a sample of old URLs. Confirm that a public article reaches its corresponding frontend page in a clear path.
Also update links you control. Removing backend URLs from navigation and content reduces reliance on redirects and makes the intended architecture clearer to readers.
Verify the next publication, not only old records
Publish or update a controlled test record through the normal workflow. Confirm that the frontend page, canonical, and sitemap all use the intended route without manual repair.
Test a slug change and a new content type if those are part of the supported publishing process. The mapping should remain coherent when editorial state changes.
For a release handoff, state which system now owns public URL generation and how other systems consume it. That ownership is the durable fix.
Monitor the next routine CMS import or deployment. If old backend hosts return, the repaired output is being overwritten by another generator or stale configuration.
A clear incident conclusion names the cause and evidence: the sitemap used CMS permalinks, the generator now uses the frontend route map, and the published destinations return the correct articles.
Frequently asked questions
Can I replace the domain in every loc value?
Only after proving that the frontend paths match. Otherwise, use the actual route mapping.
Should the sitemap list WordPress API URLs?
List the public content destinations you intend readers and search systems to discover, not JSON endpoints standing in for those pages.
Does a correct sitemap fix backend canonicals?
No. Verify and repair the canonical output on the public pages separately.
Run a mapped frontend article through the free Crawlito check after the sitemap repair.
Filed under Platform guides. Topics: wordpress, sitemaps, canonical