3.0 KiB
SEO And Public Page Prerendering
Socialize is primarily a client-side app, but the public marketing pages are prerendered during the frontend build so crawlers can index static HTML.
Public Indexed Routes
These routes are treated as public site pages:
//product/product/content-planning/product/asset-revisions/product/comment-threads/product/approval-workflows/product/client-review/product/review-queues/product/audit-trail/product/workspace-access/product/team-collaboration/pricing/blogs/guides
Authenticated app routes under /app/* and auth utility routes such as /login, /register, /forgot-password, /reset-password, and /verify-email are excluded from indexing in robots.txt.
Build Flow
The frontend build runs:
vite build
vite build --ssr src/entry-public-ssr.js --outDir dist-ssr
node scripts/prerender-public.mjs
node scripts/write-public-seo.mjs
This is wired into:
cd frontend
npm run build
The prerender step writes static HTML files such as:
frontend/dist/index.html
frontend/dist/product/index.html
frontend/dist/pricing/index.html
frontend/dist/blogs/index.html
frontend/dist/guides/index.html
The SEO generator writes:
frontend/dist/robots.txt
frontend/dist/sitemap.xml
Production Domain
Set the public site URL when building for production:
cd frontend
VITE_PUBLIC_SITE_URL=https://your-domain.com npm run build
This value is used for:
- canonical URLs
- sitemap URLs
- the sitemap reference in
robots.txt
If VITE_PUBLIC_SITE_URL is not set, the build falls back to SITE_URL, then http://localhost:5173.
Files To Update
When adding, removing, or renaming public indexed pages, update all of these:
frontend/src/router/router.jsfrontend/src/entry-public-ssr.jsfrontend/scripts/prerender-public.mjsfrontend/scripts/write-public-seo.mjs- page metadata in the public page component via
usePublicPageMeta
Public page metadata helper:
frontend/src/features/landing/publicPageMeta.js
Server Routing
Caddy is configured to serve prerendered directory indexes before falling back to the SPA:
try_files {path} {path}/index.html /index.html
Config file:
deploy/caddy/Caddyfile
This matters because /product should serve dist/product/index.html, not the SPA fallback dist/index.html.
Validation
After changes:
cd frontend
VITE_PUBLIC_SITE_URL=https://your-domain.com npm run build
Check generated HTML:
grep -n "<title>" dist/product/index.html
grep -n "canonical" dist/product/index.html
grep -n "Social media content approval" dist/product/index.html
Check crawler files:
cat dist/robots.txt
cat dist/sitemap.xml
Search Engine Setup
After deployment:
- Confirm public routes return
200. - Confirm
/robots.txtand/sitemap.xmlare served. - Submit the sitemap in Google Search Console.
- Keep auth and app routes out of the sitemap unless they become public content.