🧩 Extensions
Maxim Maxim Web Developer & Entrepreneur Nov 6, 2025

Adding XML Sitemap

I've created a simple installation script that adds a comprehensive XML sitemap to your Waterhole. This helps search engines discover and index all your content.

Features

  • Multiple sitemap endpoints organized by content type
  • API-style routing (/sitemap, /sitemap/posts, etc.)
  • Automatic content discovery for channels, posts, pages, and users
  • Proper XML formatting with timestamps, change frequency, and priority
  • Error handling - won't crash if a model is missing
  • robots.txt integration with sitemap reference

Installation

Download the attached install-sitemap.sh file, upload it to your Waterhole root directory, and run:

chmod +x install-sitemap.sh
./install-sitemap.sh

That's it! The script will automatically create all necessary files and routes.

Available Endpoints

After installation, you'll have these endpoints:

  • /sitemap - Complete sitemap with all content types
  • /sitemap/posts - Posts only (limited to 1000 most recent)
  • /sitemap/channels - Channels only
  • /sitemap/pages - Static pages only
  • /sitemap/users - User profiles (limited to 500)

SEO Setup

  1. Update your domain in public/robots.txt
  2. Test your sitemap: curl https://your-domain.com/sitemap
  3. Submit to Google Search Console
  4. Submit to Bing Webmaster Tools

Code Structure

The implementation creates:

  • app/Http/Controllers/SitemapController.php - Main controller with 5 methods
  • Routes in routes/web.php using prefix grouping
  • public/robots.txt with sitemap reference

Each URL includes:

  • <loc> - Full URL
  • <lastmod> - Last modification timestamp
  • <changefreq> - Update frequency hint
  • <priority> - Relative importance (0.0-1.0)

Why Multiple Endpoints?

For large forums, splitting the sitemap by content type:

  • Makes it easier to debug specific content issues
  • Allows selective reindexing in search consoles
  • Keeps individual sitemaps under the 50k URL limit
  • Improves crawl efficiency

Customization

You can adjust limits in the controller:

  • Posts: currently limit(1000)
  • Users: currently limit(500)
  • Channels and Pages: no limit (usually small)

Notes

  • No .xml extension needed - XML content type is set via headers
  • Clean URLs follow the same pattern as the Waterhole API
  • Error handling prevents crashes if models aren't available
  • Works with unlicensed Waterhole installations

Hope this helps improve your forum's SEO! 🚀

Attachment: install-sitemap.sh

❤️ 3 Love Loading...
2 ⁨2⁩ ⁨comments⁩

⁨2⁩ ⁨Comments⁩

Thank you for your sharing.

After adding the custom routes in WaterholeServiceProvider.php, it worked successfully — really appreciate!

Route::prefix('sitemap')->group(function () {
    Route::get('/', [\App\Http\Controllers\SitemapController::class, 'index']);
    Route::get('/posts', [\App\Http\Controllers\SitemapController::class, 'posts']);
    Route::get('/channels', [\App\Http\Controllers\SitemapController::class, 'channels']);
    Route::get('/pages', [\App\Http\Controllers\SitemapController::class, 'pages']);
    Route::get('/users', [\App\Http\Controllers\SitemapController::class, 'users']);
});