import fs from "fs"; import path from "path"; import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const mainDirectory = 'https://www.pozo.app'; const routes = [ { path: "index.html", pageId: 1, url: `${mainDirectory}/`}, { path: "signin/index.html", pageId: 2, url: `${mainDirectory}/signin` }, { path: "home/pricing-pozoapp/index.html", pageId: 3, url: `${mainDirectory}/pricing` }, { path: "contact-us/index.html", pageId: 4, url: `${mainDirectory}/contact-us` }, { path: "blog/index.html", pageId: 5, url: `${mainDirectory}/blog` }, { path: "about-us/index.html", pageId: 6, url: `${mainDirectory}/about-us` }, { path: "solutions/index.html", pageId: 9, url: `${mainDirectory}/solutions` }, ]; const seoData = { 1: { title: "Retail ERP & POS for Indian MSMEs | POZO", description: "Fast billing, smart inventory, GST-ready POS. POZO helps kirana, mini-supermarkets & retail chains speed checkout, connect weighing scales, and manage multi-store ops.", keywords: "retail ERP, POS software, billing software, inventory management, GST billing, kirana store, mini supermarket, weighing scale POS, multi-store ERP, Indian retail software", image: `${mainDirectory}/og/home.jpg`, }, 2: { title: "Sign In to PozoApp | Retail ERP & POS Login", description: "Access your business dashboard. Sign in to POZO retail ERP & POS system for billing, inventory management, and business analytics.", keywords: "POZO login, retail ERP login, POS software login, business dashboard, billing software access, inventory management login", image: `${mainDirectory}/og/Signin-og.jpg`, }, 3: { title: "Pricing - Retail ERP & POS Plans | POZO", description: "Simple plans for MSMEs. Fast billing, inventory, GST e-invoice, weighing-scale integration, WhatsApp e-bills & multi-store controls. Book a demo.", keywords: "POZO pricing, retail ERP pricing, POS software cost, billing software price, inventory management pricing, GST software cost, MSME software pricing", image: `${mainDirectory}/og/pricing-og.jpg`, }, 4: { title: "Contact POZO | Retail ERP & POS Support", description: "Get support and sales information for POZO retail ERP & POS solutions. Contact us for billing software, inventory management, and business automation.", keywords: "POZO contact, retail ERP support, POS software support, billing software help, inventory management support, customer service, technical support", image: `${mainDirectory}/og/contact-og.jpg`, }, 5: { title: "POZO Blog — Retail ERP, POS & Grocery Billing Guides", description: "Practical guides on POS billing, weighing-scale integration, GST e-invoices, multi-store ERP & inventory control for Indian retailers.", keywords: "retail blog, POS guides, billing tutorials, inventory tips, GST billing guide, weighing scale integration, multi-store management, retail technology", image: `${mainDirectory}/og/blog-og.jpg`, }, 6: { title: "About POZO | Retail ERP & POS Solutions for MSMEs", description: "Learn about POZO's mission to digitize Indian retail businesses with affordable ERP & POS solutions, billing software, and inventory management.", keywords: "about POZO, retail digitization, MSME solutions, Indian retail software, ERP for small business, POS for kirana stores, retail technology company", image: `${mainDirectory}/og/about-og.jpg`, }, 9: { title: "Retail Solutions | ERP & POS Software for Every Business", description: "Comprehensive retail solutions: billing software, inventory management, GST compliance, weighing scale integration, and multi-store ERP for Indian businesses.", keywords: "retail solutions, comprehensive ERP, POS solutions, billing solutions, inventory solutions, GST compliance software, weighing scale POS, multi-store solutions", image: `${mainDirectory}/og/solutions-og.jpg`, }, }; async function generateSEOFiles() { for (const route of routes) { const pageSeo = seoData[route.pageId]; const filePath = path.join(__dirname, "../dist", route.path); fs.mkdirSync(path.dirname(filePath), { recursive: true }); let html; if (fs.existsSync(filePath)) { html = fs.readFileSync(filePath, "utf8"); } else { html = fs.readFileSync(path.join(__dirname, "../dist/index.html"), "utf8"); } // Remove ONLY SEO-specific tags, preserve verification and analytics html = html .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, '') .replace(/]*>/g, ''); // Replace title html = html.replace(/[^<]*<\/title>/g, `<title>${pageSeo.title}`); // Add verification tags and analytics if not present const verificationTags = ` `; // Add all new SEO tags after title const newSeoTags = `${verificationTags} `; // Only add verification tags if they don't exist if (!html.includes('google-site-verification') && !html.includes('gtag')) { html = html.replace(/([^<]*<\/title>)/, `$1${newSeoTags}`); } else { // Just add SEO tags without verification const seoOnlyTags = ` <!-- SEO Meta Tags --> <meta name="description" content="${pageSeo.description}" /> <meta name="keywords" content="${pageSeo.keywords}" /> <!-- Open Graph / Facebook --> <meta property="og:type" content="website" /> <meta property="og:url" content="${route.url}" /> <meta property="og:title" content="${pageSeo.title}" /> <meta property="og:description" content="${pageSeo.description}" /> <meta property="og:image" content="${pageSeo.image}" /> <!-- Twitter --> <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:url" content="${route.url}" /> <meta name="twitter:title" content="${pageSeo.title}" /> <meta name="twitter:description" content="${pageSeo.description}" /> <meta name="twitter:image" content="${pageSeo.image}" /> <link rel="canonical" href="${route.url}" />`; html = html.replace(/(<title>[^<]*<\/title>)/, `$1${seoOnlyTags}`); } // Add GTM noscript to body if not present if (!html.includes('GTM-W2NQZPX')) { html = html.replace( '<body>', `<body> <!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W2NQZPX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) -->` ); } // Add AOS script before closing body tag if (!html.includes('aos.js')) { html = html.replace( '</body>', ` <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script> </body>` ); } fs.writeFileSync(filePath, html); console.log(`✓ Generated ${route.path} with complete SEO`); console.log(` Title: ${pageSeo.title}`); console.log(` Image: ${pageSeo.image}`); console.log(` URL: ${route.url}`); console.log(''); } console.log("✓ All SEO files fixed with verification tags!"); } generateSEOFiles().catch(console.error);