From 430444d9415b804828c6fcae5ccb9991c551d935 Mon Sep 17 00:00:00 2001 From: anurag629 Date: Thu, 16 Jul 2026 14:42:32 +0530 Subject: [PATCH] feat(seo): add env-driven search-engine verification meta tags Render the Google Search Console and Bing Webmaster ownership meta tags from GOOGLE_SITE_VERIFICATION / BING_SITE_VERIFICATION env vars. Tokens are never committed, and the tags only render when a token is set, so previews and forks stay clean. Both are optional and documented in the README. Closes #26 --- README.md | 7 +++++++ app/layout.tsx | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index bebcc38..3e47e59 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,13 @@ npm run test # vitest unit tests (lib/) The app deploys to any Node host. On Vercel, import the repo and it builds with zero config. There are no required environment variables. If you fork it, update the domain in `lib/tools.ts` (`SITE_URL`) and `app/robots.ts` so the sitemap and canonical URLs point at your host, and update `GITHUB_REPO` in `lib/tools.ts` so the star-count link points at your fork. +Optional environment variables (all safe to omit): + +| Variable | Purpose | +|----------|---------| +| `GOOGLE_SITE_VERIFICATION` | Renders the Google Search Console `google-site-verification` meta tag so you can verify ownership of the property. | +| `BING_SITE_VERIFICATION` | Renders the Bing Webmaster Tools (`msvalidate.01`) verification meta tag. | + ## Add a tool The tool set is a single typed registry in [`lib/tools.ts`](lib/tools.ts). The home grid, per-tool metadata, JSON-LD (SoftwareApplication, breadcrumb, FAQ), social share images, hero, FAQ, CTA, sitemap, web manifest, and command palette all derive from it. To add a tool: diff --git a/app/layout.tsx b/app/layout.tsx index 185d7f5..4aae2c3 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -36,6 +36,21 @@ const THEME_INIT = `(function(){try{var t=localStorage.getItem("cc:theme");if(t! // are marked noindex so they never get crawled or compete with production. const IS_NON_PROD = Boolean(process.env.VERCEL_ENV) && process.env.VERCEL_ENV !== "production"; +// Search-engine ownership verification tags. Tokens come from env so they are +// configurable per deployment and never committed; the tags render only when a +// token is set, so previews and forks stay clean. Both are optional. +const googleVerification = process.env.GOOGLE_SITE_VERIFICATION; +const bingVerification = process.env.BING_SITE_VERIFICATION; +const verification: Metadata = + googleVerification || bingVerification + ? { + verification: { + ...(googleVerification ? { google: googleVerification } : {}), + ...(bingVerification ? { other: { "msvalidate.01": bingVerification } } : {}), + }, + } + : {}; + export const metadata: Metadata = { metadataBase: new URL("https://tools.codercops.com"), title: { @@ -46,6 +61,7 @@ export const metadata: Metadata = { "Free, fast, privacy-first developer tools: JSON formatter, JWT decoder, Base64 encoder, and more. Runs entirely in your browser.", applicationName: "CODERCOPS Tools", authors: [{ name: "CODERCOPS", url: "https://www.codercops.com" }], + ...verification, ...(IS_NON_PROD ? { robots: { index: false, follow: false } } : {}), openGraph: { type: "website",