From f97edf35f4e27f40fe27c723aa06084c46485c4e Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Wed, 3 Sep 2025 15:08:38 +0000 Subject: [PATCH] Add a sitemap to help search engines find all video content Add a new GET endpoint to '/sitemap.xml' that generates an XML sitemap containing all video pages, improving SEO discoverability. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1/gjpMN2A --- server/routes.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/server/routes.ts b/server/routes.ts index a6ceddc..d181c82 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -1270,6 +1270,42 @@ export async function registerRoutes(app: Express): Promise { } }); + // SEO - Sitemap XML with all video pages + app.get('/sitemap.xml', async (req, res) => { + try { + const videos = await storage.getVideos(1, 1000); // Get all videos + const baseUrl = 'https://go4.video'; + + let sitemap = ` + + + ${baseUrl}/ + daily + 1.0 + ${new Date().toISOString().split('T')[0]} + `; + + // Add all video pages + videos.forEach(video => { + sitemap += ` + + ${baseUrl}/video/${video.id} + weekly + 0.8 + ${video.updatedAt ? video.updatedAt.toISOString().split('T')[0] : new Date().toISOString().split('T')[0]} + `; + }); + + sitemap += '\n'; + + res.set('Content-Type', 'application/xml'); + res.send(sitemap); + } catch (error) { + console.error('Error generating sitemap:', error); + res.status(500).send('Error generating sitemap'); + } + }); + const httpServer = createServer(app); return httpServer; }