From 0594d5ec14db17d287faf716626746acae651cd8 Mon Sep 17 00:00:00 2001 From: Bhav-ikkk Date: Sat, 7 Mar 2026 20:19:22 +0530 Subject: [PATCH 1/2] feat(seo): add comprehensive SEO engine with JSON-LD, Open Graph, and per-page components - Add src/components/SEO/ directory with complete SEO engine - seo.config.js: site identity, domain, geo, social handles - schemas.js: 7 JSON-LD builders (WebSite, Organization, Event, Breadcrumb, FAQ, ImageGallery) - SEOHead.js: core Head component with OG, Twitter Cards, AI/LLM meta - 10 per-page SEO components (HomeSEO, AboutSEO, EventsSEO, etc.) - Add public/robots.txt with crawler directives and sitemap reference - Add src/pages/sitemap.xml.js with dynamic event sitemap generation - Add SSR data fetching to events/[id] for SEO-friendly event pages - Update _app.js: remove duplicate OG tags, keep only PWA meta - Update _document.js: add geo tags, author, publisher meta - Integrate SEO into: home, events, event detail, team, gallery, cart, checkout pages --- public/robots.txt | 30 +++ src/components/SEO/SEOHead.js | 91 ++++++++ src/components/SEO/index.js | 44 ++++ src/components/SEO/pages/AboutSEO.js | 56 +++++ src/components/SEO/pages/CartSEO.js | 15 ++ src/components/SEO/pages/CheckoutSEO.js | 15 ++ src/components/SEO/pages/EventDetailSEO.js | 61 +++++ src/components/SEO/pages/EventsSEO.js | 26 +++ src/components/SEO/pages/GallerySEO.js | 26 +++ src/components/SEO/pages/HomeSEO.js | 30 +++ src/components/SEO/pages/LoginSEO.js | 15 ++ src/components/SEO/pages/RegisterSEO.js | 25 ++ src/components/SEO/pages/TeamSEO.js | 26 +++ src/components/SEO/schemas.js | 253 +++++++++++++++++++++ src/components/SEO/seo.config.js | 53 +++++ src/pages/_app.js | 16 +- src/pages/_document.js | 12 + src/pages/cart/index.js | 2 + src/pages/checkout/index.js | 2 + src/pages/events/[id].js | 43 +++- src/pages/events/index.js | 2 + src/pages/gallery/index.js | 2 + src/pages/index.js | 2 + src/pages/sitemap.xml.js | 101 ++++++++ src/pages/team/index.js | 2 + 25 files changed, 937 insertions(+), 13 deletions(-) create mode 100644 public/robots.txt create mode 100644 src/components/SEO/SEOHead.js create mode 100644 src/components/SEO/index.js create mode 100644 src/components/SEO/pages/AboutSEO.js create mode 100644 src/components/SEO/pages/CartSEO.js create mode 100644 src/components/SEO/pages/CheckoutSEO.js create mode 100644 src/components/SEO/pages/EventDetailSEO.js create mode 100644 src/components/SEO/pages/EventsSEO.js create mode 100644 src/components/SEO/pages/GallerySEO.js create mode 100644 src/components/SEO/pages/HomeSEO.js create mode 100644 src/components/SEO/pages/LoginSEO.js create mode 100644 src/components/SEO/pages/RegisterSEO.js create mode 100644 src/components/SEO/pages/TeamSEO.js create mode 100644 src/components/SEO/schemas.js create mode 100644 src/components/SEO/seo.config.js create mode 100644 src/pages/sitemap.xml.js diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..e504b81 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,30 @@ +# robots.txt — Citronics 2026 (cdgicitronics.in) +# Generated for optimal Google / Bing / Edge crawling + +User-agent: * +Allow: / +Allow: /about +Allow: /events +Allow: /events/ +Allow: /gallery +Allow: /team +Allow: /register + +# Exclude auth, transactional, and private pages from indexation +Disallow: /login +Disallow: /cart +Disallow: /checkout +Disallow: /dashboard +Disallow: /tickets +Disallow: /api/ +Disallow: /401 +Disallow: /404 +Disallow: /500 +Disallow: /_next/ + +# Exclude admin routes +Disallow: /admin +Disallow: /admin/ + +# Sitemap location +Sitemap: https://cdgicitronics.in/sitemap.xml diff --git a/src/components/SEO/SEOHead.js b/src/components/SEO/SEOHead.js new file mode 100644 index 0000000..e0dc104 --- /dev/null +++ b/src/components/SEO/SEOHead.js @@ -0,0 +1,91 @@ +/** + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ SEOHead — Core Component │ + * │ │ + * │ Renders title, meta description, keywords, canonical URL, Open Graph, │ + * │ Twitter Card, and JSON-LD structured data. │ + * │ │ + * │ NOT imported directly in pages — wrapped by per-page components like │ + * │ HomeSEO, AboutSEO, etc. that pre-fill all props. │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +import Head from 'next/head' +import { SITE, buildCanonical } from './seo.config' + +const SEOHead = ({ + title, + description, + keywords, + canonicalPath = '/', + ogType = 'website', + ogImage, + noIndex = false, + schemas = [], +}) => { + const pageTitle = title || SITE.name + const pageDescription = description || `${SITE.name} — ${SITE.tagline}.` + const canonical = buildCanonical(canonicalPath) + + // Ensure OG image is absolute + const rawOgImage = ogImage || SITE.ogImage + const absoluteOgImage = rawOgImage.startsWith('http') + ? rawOgImage + : `${SITE.url}${rawOgImage.startsWith('/') ? rawOgImage : `/${rawOgImage}`}` + + return ( + + {/* ── Title ──────────────────────────────────────────── */} + {pageTitle} + + {/* ── Core meta — what crawlers and AI models read first */} + + {keywords && } + + + + + {/* ── Canonical URL ──────────────────────────────────── */} + + + {/* ── Open Graph (Facebook, WhatsApp, iMessage, etc.) ── */} + + + + + + + + + + + + + {/* ── Twitter Card ─────────────────────────────────────── */} + + + + + + + + + {/* ── AI / LLM discoverability hints ───────────────────── */} + + + + + + + {/* ── JSON-LD Structured Data ───────────────────────────── */} + {schemas.map((schema, i) => ( + sequences in JSON-LD via \u003c to prevent XSS - seo.config: add centralized fest stats (competitionCount, participantCount, departmentCount) — schemas.js now interpolates instead of hardcoding - schemas.js: remove contradictory fest-level offers block, set isAccessibleForFree: true (fest entry is free, individual events vary) - events/[id].js: fix seoEvent field mapping — event.title (not .name), event.images (not .banner_url), event.departmentName (not .department_name) - Home page: render HomeSEO inside loading/error early returns so meta tags are always present regardless of data-fetch state - Add SEO to all remaining pages: about, login, register, tickets, tickets/verify, checkout/payment-status - Create TicketsSEO, TicketVerifySEO, PaymentStatusSEO components (noindex) - sitemap.xml: paginate event fetch loop instead of hard-capping at 500 --- public/robots.txt | 6 ++-- src/components/SEO/SEOHead.js | 2 +- src/components/SEO/index.js | 3 ++ src/components/SEO/pages/GallerySEO.js | 2 +- src/components/SEO/pages/HomeSEO.js | 2 +- src/components/SEO/pages/PaymentStatusSEO.js | 15 +++++++++ src/components/SEO/pages/RegisterSEO.js | 2 +- src/components/SEO/pages/TeamSEO.js | 2 +- src/components/SEO/pages/TicketVerifySEO.js | 15 +++++++++ src/components/SEO/pages/TicketsSEO.js | 15 +++++++++ src/components/SEO/schemas.js | 19 +++-------- src/components/SEO/seo.config.js | 5 +++ src/pages/about/index.js | 2 ++ src/pages/checkout/payment-status.js | 2 ++ src/pages/events/[id].js | 6 ++-- src/pages/index.js | 34 ++++++++++++-------- src/pages/login/index.js | 2 ++ src/pages/register/index.js | 2 ++ src/pages/sitemap.xml.js | 13 ++++++-- src/pages/tickets/index.js | 2 ++ src/pages/tickets/verify.js | 2 ++ 21 files changed, 113 insertions(+), 40 deletions(-) create mode 100644 src/components/SEO/pages/PaymentStatusSEO.js create mode 100644 src/components/SEO/pages/TicketVerifySEO.js create mode 100644 src/components/SEO/pages/TicketsSEO.js diff --git a/public/robots.txt b/public/robots.txt index e504b81..0065ae6 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -12,15 +12,17 @@ Allow: /register # Exclude auth, transactional, and private pages from indexation Disallow: /login -Disallow: /cart -Disallow: /checkout Disallow: /dashboard Disallow: /tickets Disallow: /api/ Disallow: /401 Disallow: /404 Disallow: /500 + +# Next.js internals — allow render-critical JS/CSS but block image optimizer Disallow: /_next/ +Allow: /_next/static/ +Disallow: /_next/image # Exclude admin routes Disallow: /admin diff --git a/src/components/SEO/SEOHead.js b/src/components/SEO/SEOHead.js index e0dc104..41754dc 100644 --- a/src/components/SEO/SEOHead.js +++ b/src/components/SEO/SEOHead.js @@ -81,7 +81,7 @@ const SEOHead = ({