XML sitemap generator for your coupon website
Help search engines find the pages worth visiting.
A new store page can be live without being easy for a search engine to find. This happens when an offer arrives through a feed before you have linked it from a category. An XML sitemap generator gives you a machine-readable inventory of the pages you want discovered, including pages a crawler might otherwise miss.
couponPHP is a self-hosted PHP coupon and deal script. Its Sitemap Generator utility is included with Professional and higher licenses. It helps you publish that inventory for your stores, coupons, categories and content pages. Generation is one step; keeping the inventory accurate matters just as much.
What is an XML sitemap?
An XML sitemap is a structured file listing full page URLs for search engines. Each entry can also describe when the page changed. Unlike an HTML site map, which gives visitors a browsable list of links, XML is intended for automated processing.
The Sitemaps.org protocol, last updated in 2016, defines the standard format. It requires UTF-8 encoding, a urlset element with the sitemap namespace, and a url entry containing loc for each address. Other fields are optional. The protocol remains the reference for file structure, though some old submission methods described there are no longer appropriate.
Wikipedia’s Sitemaps overview explains its purpose as a URL inclusion protocol. It supplements normal link discovery. It doesn’t guarantee that a search engine will crawl or index every listed page, and submitting it doesn’t buy better rankings.
For your site, the practical distinction is discovery versus usefulness. A sitemap can identify a new store page; it can’t supply missing shopping terms or make a broken coupon work. Keep category and store navigation useful for people even when you have a complete XML file.
What the XML sitemap generator builds for couponPHP
A coupon site has several kinds of public pages, and they don’t all deserve the same publishing policy. A long-lived store guide may remain useful for years. An individual offer can become irrelevant tomorrow.
The couponPHP utility builds a site-wide sitemap covering public store, coupon and deal, category, and content-page URLs. Review the generated file against your current URL routes rather than assuming every database record should be published. Your SEO and URL controls determine the public addresses that the sitemap needs to match.
Stores and categories
Store URLs should point to your main landing pages for each merchant. A store page can stay useful when one promotion ends because it can show other offers and explain the retailer’s terms. Category URLs should lead to populated pages that help shoppers browse a real topic, rather than empty headings created by an import.
For example, an outdoor-shopping category with useful store links has a clear role. Several empty variations of that category add URLs without helping anyone. Keep your sitemap focused on the version you want people to find.
Coupons, deals and content pages
Include public offer-detail URLs when they contain enough information to help a shopper. If your chosen template shows an offer only in a popup, don’t invent a separate detail URL for the sitemap. The listed address needs to open a real public page.
Content pages can include your published shopping explanations and other indexable information. Private account screens, admin pages, internal search results and tracking redirects don’t belong in this inventory. A retailer’s affiliate destination is also not one of your site’s content URLs.
After a couponFeed import, compare a new store, a new offer and an existing category with the output. This small sample can reveal route mismatches before you submit a larger file. Confirm your build’s coverage with support if you’ve added custom page types.
File limits: 50,000 URLs and 50 MB uncompressed
A growing offer catalog can outgrow one file even when generation still works. Sitemaps.org limits each sitemap to 50,000 URLs and 50 MB uncompressed, specified as 52,428,800 bytes. Both limits apply. Gzip compression reduces transfer size, but it doesn’t raise the uncompressed limit.
When either limit would be exceeded, split the URL inventory into smaller sitemaps. A sitemap index then lists the child sitemap files. Its root element is sitemapindex, with a sitemap entry and loc for each child file. An index can list up to 50,000 sitemap files and has the same 50 MB size limit.
Separating stores from offers can also make diagnosis easier before you reach a limit. If an offers file suddenly grows, you can investigate imports without confusing them with stable information pages. This is an organizational choice, not a ranking advantage.
Ask support how splitting and index generation are handled for your installation; don’t assume the utility automatically manages every large-site configuration. Keep a safety margin below the limits. Under the standard same-site arrangement, use one canonical host and protocol, and publish at the site root so the file can cover the whole site.
Use lastmod for page changes, not generation time
A file regenerated every morning doesn’t mean every page changed that morning. Setting today’s date on an untouched store description gives crawlers inaccurate information.
The protocol defines lastmod as the page’s modification date, separate from the sitemap’s generation date. A date such as 2026-11-28 is valid. A complete date-time can include a time-zone offset when you have that level of precision. If your records don’t provide a trustworthy modification date, omit this optional field.
For a store page, a meaningful offer-list change or a rewritten explanation may justify a new value. For an individual coupon, corrected eligibility terms or a changed expiry status can be meaningful. A new visitor, an ad impression or a rotating copyright year shouldn’t reset every content date.
An index has a different meaning for its optional lastmod: it describes when the child sitemap file changed, not when every page inside it changed. Keep those timestamps separate in any custom implementation.
The optional priority and changefreq fields aren’t instructions that force crawling. Sitemaps.org also warns that assigning high priority to every URL doesn’t help. Spend your time on accurate addresses and dates before adding optional fields.
Generate, validate and publish the file
A file called sitemap.xml can still contain an HTML error page. Before announcing it, open the public address without an admin login and confirm that you receive the intended XML with a successful response.
A practical first-publication check covers these points:
- The XML parses, uses UTF-8 and contains the sitemap namespace.
- Every
locis a full URL using your chosen HTTPS host, without session IDs or unnecessary tracking parameters. - The same page doesn’t appear repeatedly under several URL variants.
- Listed pages return usable content rather than errors, login screens or redirect chains.
- Page-level canonical and indexing settings agree with the URL you have listed.
XML escaping matters. An ampersand inside a query string must be represented correctly in XML; it can’t be pasted into a text node as an unescaped character. An XML library is safer than assembling tags through string concatenation.
Publish new output only after generation finishes. Replacing a completed file is safer than allowing a crawler to read one while it is half written. If refresh fails, keep the previous valid file available and investigate the error. This publication pattern is an operational recommendation, not a claim about the utility’s internal implementation.
Submit through robots.txt and Search Console
A valid file still needs a discoverable address. Sitemaps.org supports a Sitemap: record in your site’s root robots.txt. For example:
Sitemap: https://www.example.com/sitemap.xml
If you use an index, point the line to that index instead:
Sitemap: https://www.example.com/sitemap-index.xml
Replace the example domain and filename with your real public location. The line doesn’t need its own user-agent group. It also doesn’t grant access to pages blocked elsewhere in your crawling rules.
You can submit the same sitemap or index in Google Search Console. Verify the correct site property, open its Sitemaps report, provide the file’s address or the requested path, and submit it. Check the processing status and reported errors after the search engine has attempted to fetch the file. Other search engines offer their own webmaster submission interfaces.
Submission accepted? That confirms processing, not universal indexing. If many submitted pages remain excluded, inspect representative pages rather than repeatedly resubmitting an unchanged file. The issue might be a duplicate URL, an unintended noindex instruction or an offer page with little independent value. Our affiliate SEO guide covers the wider publishing work.
Avoid following old tutorials that depend on Google’s sitemap ping URL. That submission endpoint was retired; use the robots.txt record and the current console workflow instead.
Handle expired coupons before refreshing the sitemap
Expiration is where a general sitemap checklist needs a coupon-specific decision. A code ending at midnight doesn’t automatically make the store page useless. It may make an isolated offer-detail page useless, though.
Say a store has an expired delivery discount and several current promotions. Keep the useful store URL in the sitemap. On an expired offer page, show the expiry clearly and direct shoppers to genuine current alternatives. Don’t leave a large “use code” button implying that the old offer still works.
For each expired detail page, choose based on what remains:
Keep a useful archive. A page with meaningful historical terms or an explanation people still need can remain public and indexable. It may stay in the sitemap if you still want it in search results. Expired status should be obvious before a shopper copies anything.
Retain it for users but exclude it from search. If you apply noindex, remove that URL from the sitemap. Keep the page crawlable so a search engine can read that instruction; blocking access in robots.txt can prevent that.
Remove or replace it. Delete an unwanted page with an appropriate 404 or 410 response, then remove its sitemap entry. Use a permanent redirect only when a genuine replacement exists, not as a blanket route from every expired coupon to the homepage. List the replacement URL instead.
Removing a URL from a sitemap alone doesn’t erase it from search results. The page’s response and indexing signals still matter. For pages that repeat an imported title and little else, our thin-content guide helps you assess whether keeping an archive serves a reader.
A short PHP example using XMLWriter
If you’re maintaining custom pages outside the utility’s normal coverage, an XML sitemap generator can be written with PHP’s XMLWriter extension. PHP describes it as a forward-only writer for XML streams or files. Confirm that the extension is enabled on your host.
This standalone example uses illustrative URLs and genuine example modification dates. It doesn’t represent couponPHP’s database schema or replace the supplied utility.
<?php
$pages = [
['url' => 'https://www.example.com/stores/sample/',
'lastmod' => '2026-11-27'],
['url' => 'https://www.example.com/categories/outdoors/',
'lastmod' => null],
];
$target = __DIR__ . '/sitemap.xml';
$tmp = $target . '.tmp';
$xml = new XMLWriter();
if (!$xml->openUri($tmp)) {
throw new RuntimeException('Cannot open sitemap output');
}
$xml->startDocument('1.0', 'UTF-8');
$xml->startElementNs(null, 'urlset',
'http://www.sitemaps.org/schemas/sitemap/0.9');
foreach ($pages as $page) {
$xml->startElement('url');
$xml->writeElement('loc', $page['url']);
if ($page['lastmod'] !== null) {
$xml->writeElement('lastmod', $page['lastmod']);
}
$xml->endElement();
}
$xml->endElement();
$xml->endDocument();
$xml->flush();
unset($xml);
if (!rename($tmp, $target)) {
throw new RuntimeException('Cannot publish sitemap');
}
writeElement handles XML text escaping. Supply already valid, UTF-8 URLs rather than using XML escaping as a substitute for URL encoding. A production version also needs input validation, duplicate filtering, file-size checks and error handling. Prevent overlapping runs from writing the same temporary file. Keep credentials and any private export data outside public output.
Discontinued utility: Fake Account Actions
The old Fake Account Actions utility has been discontinued because simulated user activity misleads shoppers and can violate consumer protection rules. We don’t recommend creating fictional users, votes or apparent submissions. The FTC’s 2024 fake-review guidance explains rules against fake reviews and specified false influence indicators. Use genuine shopper comments, honestly attributed submissions and real feedback instead; a quiet new site is preferable to fabricated social proof.
Frequently asked questions
Is the XML sitemap generator included with my license?
The Sitemap Generator utility is included with Professional and higher couponPHP licenses. It creates a site-wide sitemap for your public content. Ask support to confirm the utility supplied with your build, its output location and the process for refreshing it. Large sites should also confirm how sitemap splitting and index files will be handled.
Does submitting a sitemap guarantee indexing?
No. A sitemap tells search engines about URLs you want them to discover, but it does not guarantee crawling, indexing or rankings. A successful submission means the file can be processed, not that every page deserves inclusion. Keep the listed pages accessible, useful and consistent with your canonical and indexing settings.
Should expired coupons stay in the sitemap?
Keep an expired coupon URL only if the page remains useful, indexable and clearly marked as expired. A page with meaningful historical details or current alternatives can still serve readers. Remove deleted, redirected or noindex URLs from the sitemap, and keep the store page listed when it continues to offer useful information.
How often should I regenerate the sitemap?
Refresh it when your indexable URL inventory changes, such as after publishing new offers, removing pages or changing store routes. A daily publishing cycle may justify a daily refresh, but the right interval follows your actual updates. Keep lastmod tied to genuine page changes rather than stamping every URL with the generation time.
Publish the inventory you can stand behind
Before your next refresh, inspect one store, one offer, one category and one information page. Their public URLs and indexing choices should agree with the file you’re about to submit. Compare Professional and higher licenses and check the hosting requirements. For utility access or a demo on request, email support@couponphp.com; support can confirm the build for your PHP version before you proceed.
