
Implementing Sitemap Ping for Faster Crawling
When you update content frequently, you want search engines to crawl your new pages quickly. Here's how I implement sitemap generation and ping on TopVideoHub , where new trending videos are added every few hours. Generating Dynamic Sitemaps With thousands of video pages across 9 regions, a single sitemap file isn't practical. I use a sitemap index that references multiple sub-sitemaps: class SitemapGenerator { private const string BASE_URL = 'https://topvideohub.com' ; private const int MAX_URLS_PER_SITEMAP = 5000 ; public function __construct ( private readonly \PDO $db ) {} public function generateIndex (): string { $xml = '<?xml version="1.0" encoding="UTF-8"?>' . " \n " ; $xml . = '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . " \n " ; // Static pages sitemap $xml . = $this -> sitemapEntry ( 'sitemap-pages.xml' ); // Video sitemaps (paginated) $totalVideos = $this -> db -> query ( "SELECT COUNT(*) FROM videos" ) -> fetchColumn (); $pages = ceil ( $totalVide
Continue reading on Dev.to Tutorial
Opens in a new tab


