Automated Sitemap Generation

Automation

Keep your XML sitemap automatically updated using webhooks, GitHub Actions, or scheduled tasks whenever your content changes.

Why Automate Sitemap Generation?

Your sitemap should stay fresh as your content changes. Manual updates are error-prone and easy to forget. Automation ensures search engines always have the latest information about your site structure.

Always Current

Sitemap updates automatically when content changes

Better SEO

Search engines discover new content faster

Zero Maintenance

Set it up once and forget about it

Sitemap Generation API
The endpoint that triggers sitemap regeneration
POST/api/admin/sitemap/generate

Requires admin authentication. Returns the number of URLs generated and timestamp.

Example Response:

{
  "success": true,
  "urlCount": 42,
  "lastGenerated": "2024-01-15T10:30:00.000Z"
}
Method 1: GitHub Actions
Trigger sitemap generation on deployments or schedule

Perfect for sites deployed from GitHub. Automatically regenerate your sitemap when you deploy new content or on a schedule.

1. Create Workflow File

Create .github/workflows/sitemap.yml in your repository:

name: Update Sitemap

on:
  # Trigger after successful deployment
  workflow_run:
    workflows: ["Deploy"]
    types: [completed]
    branches: [main]
  
  # Or run on a schedule (daily at 2 AM UTC)
  schedule:
    - cron: '0 2 * * *'
  
  # Allow manual trigger
  workflow_dispatch:

jobs:
  update-sitemap:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
    
    steps:
      - name: Trigger Sitemap Generation
        run: |
          curl -X POST \
            -H "Authorization: Bearer ${{ secrets.SITEMAP_API_KEY }}" \
            -H "Content-Type: application/json" \
            -d '{}' \
            "${{ secrets.SITE_URL }}/api/admin/sitemap/generate"

2. Add Repository Secrets

Go to your GitHub repository → Settings → Secrets and variables → Actions:

SITE_URLhttps://yourdomain.com
SITEMAP_API_KEYYour admin API key
Method 2: Coolify Scheduled Tasks
Use Coolify's built-in task scheduler

If you're using Coolify for deployment, you can set up scheduled tasks directly in the Coolify dashboard.

1. Access Scheduled Tasks

  1. Open your Coolify dashboard
  2. Navigate to your application
  3. Go to "Scheduled Tasks" tab
  4. Click "Add New Task"

2. Configure the Task

Name
Update Sitemap
Schedule
0 2 * * *
Command
curl -X POST \
  -H "Authorization: Bearer $SITEMAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}' \
  "$SITE_URL/api/admin/sitemap/generate"

3. Set Environment Variables

Add these to your application's environment variables in Coolify:

SITE_URLhttps://yourdomain.com
SITEMAP_API_KEYYour admin API key
Method 3: Webhooks
Trigger from CMS updates or external events

Set up webhooks to regenerate your sitemap when content changes in your CMS, forms are submitted, or other events occur.

Webhook Endpoint Setup

Configure your CMS or service to send a POST request to:

https://yourdomain.com/api/admin/sitemap/generate

Required Headers

All webhook requests must include these headers:

AuthorizationBearer your-sitemap-api-key
Content-Typeapplication/json

Postman Setup

Test your webhook endpoint using Postman:

1. Create New Request
  • • Method: POST
  • • URL: https://yourdomain.com/api/admin/sitemap/generate
2. Set Headers
Key
Authorization
Content-Type
Value
Bearer your-sitemap-api-key
application/json
3. Set Body

Select "raw" and "JSON" format, then use:

{}
4. Expected Response
{
  "success": true,
  "urlCount": 42,
  "lastGenerated": "2024-01-15T10:30:00.000Z"
}

Common Webhook Sources

Content Management
  • • Strapi
  • • Contentful
  • • Sanity
  • • Ghost
E-commerce
  • • Shopify
  • • WooCommerce
  • • Medusa
  • • Saleor

Example: Strapi Webhook

  1. Go to Settings → Webhooks in your Strapi admin
  2. Click "Create new webhook"
  3. Set URL to your sitemap generation endpoint
  4. Add Authorization header with your API key
  5. Select events: Entry create, update, delete
Authentication Setup
Secure your sitemap generation endpoint

Option 1: API Key (Recommended)

Create a dedicated API key for sitemap generation:

# Add to your environment variables
SITEMAP_API_KEY=your-secure-api-key-here

# Use in Authorization header
Authorization: Bearer your-secure-api-key-here

Option 2: Session-Based

Use your existing admin session cookies (less suitable for automation).

Testing Your Setup
Verify everything works correctly

Manual Test

Test the endpoint manually using curl:

curl -X POST \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{}' \
  "https://yourdomain.com/api/admin/sitemap/generate"

Verify Results

  1. Check the API response for success status
  2. Visit /sitemap.xml to see the updated sitemap
  3. Check the admin panel for the last generation timestamp
  4. Monitor your automation logs for any errors
Best Practices

✅ Do

  • • Set up monitoring for failed generations
  • • Use secure API keys with limited scope
  • • Test in staging before production
  • • Set reasonable rate limits
  • • Monitor sitemap file size

❌ Don't

  • • Generate sitemaps too frequently (1 hour)
  • • Expose API keys in client-side code
  • • Skip error handling in automation
  • • Forget to update webhooks when URLs change
  • • Generate sitemaps for every minor change
Troubleshooting

Common Issues

401 Unauthorized

Check your API key or authentication headers. Ensure SITEMAP_API_KEY is set in your environment variables.

Invalid Input: Expected Object, Received Undefined

Include an empty JSON object {} in the request body, even if no data is needed. Set Content-Type to application/json.

500 Server Error

Check server logs and database connectivity. Verify SITEMAP_API_KEY environment variable is configured.

Webhook Not Triggering

Verify webhook URL and check CMS webhook logs. Ensure the Authorization header is properly formatted.

Elder & Estate

Protecting your legacy, one plan at a time.

Elder and Estate is an online service providing legal forms and information. Elder and Estate is not a law firm and cannot provide legal advice. Elder and Estate is not a substitute for an attorney or law firm. Communications between you and Elder and Estate are protected by our Privacy Policy, not by attorney-client privilege. 2025 Elder and Estate, Inc.

Estate Planning - Create an Online Will and Trust | Elder and Estate