Site Generator
The site generator is a Go application in site/ that produces tens of thousands of static HTML pages. It uses HTML templates, JSON data, and SQLite queries to generate SEO-optimized pages for every Brazilian city and state.
How It Works
- Load data — Read geographic data (states, cities), scopes, topics, and special page configs from SQLite
- Generate pages — For each combination of scope/state/city/topic, render an HTML template with injected data
- Write output — Save files to
site/public/in a folder-per-URL structure (/casas/sao-paulo/index.html) - Copy static assets — Copy CSS, JS, images to
site/public/static/ - Generate sitemap — Traverse
public/and writesitemap.xml
Key Files
| File | Purpose |
|---|---|
main.go | CLI entry point and command routing |
cmd_build.go | build-pages and build-static commands |
cmd_pages.go | Single page builders (build-page) |
cmd_daily.go | daily-update rotating refresh |
cmd_notfound.go | 404 CSV processing and missing page generation |
cmd_sitemap.go | Sitemap generation command |
cmd_helper.go | Shared template rendering helpers |
helpers.go | HTML generation utilities |
templates/ | HTML templates for every page type |
Templates
Templates are Go html/template files in site/templates/:
| Template | Used For |
|---|---|
home.html | Homepage |
casas_index.html | Scope index pages |
casas_state.html | State index pages |
city.html | City detail pages |
topic_index.html | Topic index pages |
topic_state.html | Topic + state pages |
topic_city.html | Topic + city pages |
blog_post.html | Blog articles |
chat.html | Chat application page |
auth_login.html | Login page |
auth_register.html | Register page |
auth_account.html | User dashboard |
Templates receive a data struct containing:
- Page metadata (title, description, canonical URL)
- Geographic context (state name, city name, scope name)
- Content blocks (pre-rendered HTML snippets)
- Navigation links
Output Structure
site/public/├── index.html # Home├── casas/│ ├── index.html # Scope index│ ├── sao-paulo/│ │ ├── index.html # State index│ │ ├── sao-paulo/│ │ │ └── index.html # City page│ │ └── campinas/│ │ └── index.html # City page│ └── ... (other states)├── jardim/ # Same structure├── condominios/ # Same structure├── energia-solar/ # Topic pages├── iptu/├── blog/├── chat/├── login/├── register/├── conta/├── static/│ ├── css/│ ├── js/│ └── images/└── sitemap.xml