Pular para o conteúdo

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

  1. Load data — Read geographic data (states, cities), scopes, topics, and special page configs from SQLite
  2. Generate pages — For each combination of scope/state/city/topic, render an HTML template with injected data
  3. Write output — Save files to site/public/ in a folder-per-URL structure (/casas/sao-paulo/index.html)
  4. Copy static assets — Copy CSS, JS, images to site/public/static/
  5. Generate sitemap — Traverse public/ and write sitemap.xml

Key Files

FilePurpose
main.goCLI entry point and command routing
cmd_build.gobuild-pages and build-static commands
cmd_pages.goSingle page builders (build-page)
cmd_daily.godaily-update rotating refresh
cmd_notfound.go404 CSV processing and missing page generation
cmd_sitemap.goSitemap generation command
cmd_helper.goShared template rendering helpers
helpers.goHTML generation utilities
templates/HTML templates for every page type

Templates

Templates are Go html/template files in site/templates/:

TemplateUsed For
home.htmlHomepage
casas_index.htmlScope index pages
casas_state.htmlState index pages
city.htmlCity detail pages
topic_index.htmlTopic index pages
topic_state.htmlTopic + state pages
topic_city.htmlTopic + city pages
blog_post.htmlBlog articles
chat.htmlChat application page
auth_login.htmlLogin page
auth_register.htmlRegister page
auth_account.htmlUser 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