NGU-Web/docs/seo.md
Zaldimmar e932ee3007 Show Google sign-in even when site.json isn't deployed
/api/auth/providers read site.json to build Google's return address,
and the deploy copies server/ into /srv/ngu-api without site.json, so
it threw and the login page hid the button. Whether Google is on now
depends only on the client id and secret; a missing return address is
logged when a sign-in starts, naming GOOGLE_REDIRECT_URI and
SITE_CONFIG. The docs say how the server is actually deployed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 21:51:40 -05:00

3.6 KiB

Search and link previews

Each page's HTML carries its own title, description, preview image, canonical address and, where it fits, structured data, so a link shared on Facebook, iMessage, Slack, Discord or X shows that page, and search engines see the right title before any JavaScript runs.

The API does this: nginx sends page requests to it, and it fills the built index.html in for that path (server/src/routes/pages.js, rules in server/src/pageMeta.js). It also serves /sitemap.xml.

Where the words come from

What Where
Site name, address, default description site.json: title, url, description (blank uses the front page's subhead)
Default preview image site.json: openGraph.image, eg. /uploads/<file> from Admin → Tools → Media. Blank means pages without their own image have none.
Static pages (Retreats, Community, History…) site.json: pages. The page's heading and intro read the same entry, so they can't drift. A new static page needs an entry.
Records (events, organizations, teams, awards, people, posts) The database: the record's name, then its tagline or first paragraph; its own image (an event's card background, else its logo; a post's cover; a person's photo; an organization's logo). SVGs aren't used as previews.
Whether search may list it site.json robots.index for the whole site; per record, published and listed is indexed, published but unlisted is noindex, anything else is a 404. /admin is always noindex.

Structured data: Organization on the home page, Event on event pages, BlogPosting on posts.

robots.txt is written by the build (vite.config.ts): with indexing on it allows everything but /admin and /api and names the sitemap; with it off it blocks everything.

Production setup

  1. The API needs to find two files. Both default to the repo layout (site.json at the root, the build in dist/), which isn't how the server is deployed: the deploy copies server/ into /srv/ngu-api, so neither file is next to it. Copy site.json there with each deploy (eg. rsync it to /srv/ngu-api/site.json) and set both on the ngu-api unit:

    [Service]
    Environment=SITE_CONFIG=/srv/ngu-api/site.json
    Environment=SITE_INDEX=/path/to/the/built/site/index.html
    

    index.html is reread when it changes, so a frontend deploy doesn't need an API restart.

  2. In the nginx site, serve files that exist, send everything else to the API, and fall back to the plain index.html if the API is down, so the site still loads (with default previews) during a restart:

    location = /sitemap.xml {
        proxy_pass http://127.0.0.1:3001;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    
    location / {
        try_files $uri @page;
    }
    
    location @page {
        proxy_pass http://127.0.0.1:3001;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_intercept_errors on;
        error_page 502 503 504 = @static;
    }
    
    location @static {
        try_files /index.html =404;
    }
    

    Keep the existing /api/ and /uploads/ blocks; they're more specific and still win. Use the port the API listens on.

  3. Check it: curl -s https://nextgenerationofunity.org/events/<id> | grep og:title should show the event's name, and Facebook's Sharing Debugger or https://www.opengraph.xyz will show the preview.

  4. Tell Google: add the site in Google Search Console and submit https://nextgenerationofunity.org/sitemap.xml.