Pular para o conteúdo

Templates

The site generator uses Go’s html/template package to render pages. Templates live in site/templates/ and are rendered with data structs populated from the database.

Template Types

Layout Template

layout.html is the base template that all other templates extend. It contains:

  • <head> with meta tags, title, CSS links
  • Navigation bar
  • Footer
  • Common scripts

Page templates inject their content into blocks defined by the layout.

Page Templates

TemplatePage Type
home.htmlHomepage with featured content
casas_index.htmlScope index (lists all states)
casas_state.htmlState index (lists cities in state)
city.htmlCity detail page with local content
topic_index.htmlTopic overview page
topic_state.htmlTopic applied to a state
topic_city.htmlTopic applied to a city
blog_post.htmlIndividual blog article
chat.htmlStandalone chat application
auth_*.htmlAuthentication pages (login, register, account)

Data Model

Each template receives a struct with:

type PageData struct {
Title string
Description string
Canonical string
StateName string
CityName string
ScopeName string
Content template.HTML
Links []Link
Meta MetaTags
}

Content Injection

Pre-rendered HTML content is stored in page_content_cache and injected into templates:

  1. Generator queries page_content_cache for the requested page
  2. If cache miss or stale, generates new content (possibly with AI)
  3. Renders the template with the cached content block
  4. Writes the final HTML to public/

Adding a New Template

  1. Create the HTML file in site/templates/
  2. Add a builder function in cmd_pages.go or a new cmd_*.go
  3. Register the page type in the CLI command router
  4. Add data loading logic in cmd_helper.go
  5. Test with go run . build-page <new-type>