vkashti / next-sitemap.config.js
next-sitemap.config.js
Raw
/** @type {import('next-sitemap').IConfig} */
module.exports = {
    siteUrl: 'https://www.vkashti.bar', // Your site's URL
    generateRobotsTxt: true, // Generate robots.txt
    exclude: [
        '/admin/*',
        '/auth/*',
        '/signin/*',
        '/account/*',
        '/api/*',  // Excluding API routes
    ],
    transform: async (config, path) => {
        // Define path priorities
        const priorityMap = {
            '/': 1.0,                     // Homepage gets highest priority
            '/menu': 0.9,                 // Core business pages
            '/events': 0.9,
            '/quiz': 0.8,
            '/reservations': 0.8,
            '/deals': 0.8,
            '/services': 0.8,             // Increased priority for services page
            '/careers': 0.7,
        };
        
        // Set specific priorities for service pages
        if (path.startsWith('/services/')) {
            return {
                loc: path,
                changefreq: 'weekly',
                priority: 0.7,
                lastmod: new Date().toISOString(),
            };
        }

        // Set default priority if not in map
        const priority = priorityMap[path] || 0.6;

        // Set changefreq based on path
        let changefreq = 'weekly';
        if (path === '/') changefreq = 'daily';
        if (path.includes('/events')) changefreq = 'daily';
        if (path.includes('/deals')) changefreq = 'daily';
        if (path.includes('/menu')) changefreq = 'weekly';
        
        return {
            loc: path,
            changefreq,
            priority,
            lastmod: new Date().toISOString(),
        };
    },
    additionalPaths: async (config) => [
        // Main pages
        { loc: '/', priority: 1.0, changefreq: 'daily' },
        { loc: '/events', priority: 0.9, changefreq: 'daily' },
        { loc: '/menu', priority: 0.9, changefreq: 'weekly' },
        { loc: '/quiz', priority: 0.8, changefreq: 'weekly' },
        { loc: '/reservations', priority: 0.8, changefreq: 'weekly' },
        { loc: '/deals', priority: 0.8, changefreq: 'daily' },
        { loc: '/careers', priority: 0.7, changefreq: 'monthly' },
        
        // Services pages
        { loc: '/services', priority: 0.8, changefreq: 'weekly' },
        { loc: '/services/birthdays', priority: 0.7, changefreq: 'weekly' },
        { loc: '/services/companies', priority: 0.7, changefreq: 'weekly' },
        { loc: '/services/hire-barman', priority: 0.7, changefreq: 'weekly' },
        { loc: '/services/quizes', priority: 0.7, changefreq: 'weekly' },
        { loc: '/services/live-music', priority: 0.7, changefreq: 'weekly' },
        { loc: '/services/become-barman', priority: 0.7, changefreq: 'weekly' },
        { loc: '/services/board-games', priority: 0.7, changefreq: 'weekly' },
        { loc: '/services/coworking', priority: 0.7, changefreq: 'weekly' },
    ],
    robotsTxtOptions: {
        policies: [
            {
                userAgent: '*',
                allow: '/',
                disallow: ['/admin', '/auth', '/signin', '/account', '/api']
            }
        ],
        additionalSitemaps: [],
    }
};