How to Extract All Product URLs from Your Webstore Sitemap

494 views · 2 min read · Tutorials

Overview

Every commercebuild webstore automatically generates XML sitemaps that contain all published product URLs. You can use these sitemaps to quickly export a complete list of product page URLs into a plain text file, useful for audits, redirects, migrations, or SEO checks.

There are two sitemap sources you can use depending on your needs:

Sitemap URL Pattern Best For
Google Product Sitemap https://www.yourstore.com/sitemap_google_products.xml Product URLs with Google Shopping data
Products Sitemap https://www.yourstore.com/sitemap_products.xml Clean list of all product page URLs

How It Works

Prerequisites

  • Terminal access (macOS Terminal, Linux shell, or Windows WSL)

  • curl and sed (pre-installed on macOS/Linux)

  • Replace www.yourstore.com in all examples below with your actual webstore URL


Option 1: Download and Extract from Google Product Sitemap

This method downloads the sitemap file first, then parses it locally.

Step 1: Download the sitemap:

Visit this URL in your browser (replacing the domain with yours):

https://www.yourstore.com/sitemap_google_products.xml

Save the file to your working directory.

Step 2: Extract product URLs:

Run this in your terminal from the same directory:

sed -n '/<g:link>/,/<\/g:link>/ s/.*\(https:[^ ]*\).*/\1/p' sitemap_google_products.xml > product_urls.txt

This parses the <g:link> tags in the Google Product feed and outputs each product URL to product_urls.txt.

Option 2: One-Liner Using curl (No Manual Download)

This method fetches and parses the sitemap in a single command, no need to download the file first.

curl -sL "https://www.yourstore.com/sitemap_products.xml" \
| sed -n 's/.*<loc>\(.*\)<\/loc>.*/\1/p' \
> product-urls.txt

What it does:

  1. curl -sL silently fetches the sitemap (follows redirects).

  2. sed extracts the URL from each <loc>...</loc> tag.

  3. > product-urls.txt writes all URLs to a text file in your current directory.


Before You Run

⚠️ Replace www.yourstore.com with your actual webstore domain in any command above. For example, if your store is www.example-store.com:

curl -sL "https://www.example-store.com/sitemap_products.xml" \
| sed -n 's/.*<loc>\(.*\)<\/loc>.*/\1/p' \
> product-urls.txt

Output

Both methods produce a plain text file with one product URL per line:

https://www.yourstore.com/product-name-1/
https://www.yourstore.com/product-name-2/
https://www.yourstore.com/category/product-name-3/
...

Conclusion

Use your webstore’s built-in XML sitemaps to quickly export all product URLs without needing database access or admin exports.

Was this article helpful?

Thanks for the feedback.

Need further assistance?

Email support@commercebuild.com or open a ticket and we'll get back to you.

Submit a ticket