A modern Go web application starter template with HTMX, Alpine.js, and TailwindCSS.
- Go - Clean, fast backend with structured routing
- HTMX - Dynamic frontend interactions without JavaScript complexity
- Alpine.js - Lightweight JavaScript framework for reactivity
- TailwindCSS - Utility-first CSS framework
- Live Reload - Air integration for development hot reloading
- Static Asset Caching - Built-in ETag support for efficient caching
- Feature-Based Architecture - Organized by features (vertical slices) for better maintainability
- Go 1.24.2 or later
- Node.js (for TailwindCSS and frontend dependencies)
-
Clone the repository:
git clone <your-repo-url> cd ct-go-web-starter
-
Install dependencies:
npm install go mod tidy
-
Build CSS and assets:
go generate
-
Run the development server:
air
The application will be available at http://localhost:8080
├── src/
│ ├── features/ # Feature-based organization (vertical slices)
│ │ └── home/ # Home page feature
│ │ ├── handler.go # HTTP handler for home routes
│ │ └── home.html # Feature-specific template
│ ├── shared/ # Shared components and utilities
│ │ ├── components/ # Reusable UI components
│ │ │ ├── header/ # Header component
│ │ │ └── footer/ # Footer component
│ │ ├── templates/ # Base page templates
│ │ └── utils/ # Common utility functions
│ ├── infrastructure/ # Cross-cutting infrastructure concerns
│ │ ├── config/ # Configuration and logging
│ │ └── fileserver/ # Static file serving with caching
│ ├── static/ # Static assets (favicon, images, etc.)
│ ├── styles/ # TailwindCSS source files
│ └── app.go # Application setup and routing
├── scripts/ # Build scripts
├── build/ # Generated assets (not in git)
├── .air.toml # Live reload configuration
└── package.json # Frontend dependencies
air
- Start development server with live reloadgo run main.go
- Run without live reloadgo generate
- Build CSS and copy assetsnpm run build-css
- Build TailwindCSS only
- Create a new feature directory in
src/features/
- Add handler.go and feature-specific templates
- Register routes in
src/app.go
- Use shared components from
src/shared/components/
Example: Adding a "blog" feature
src/features/blog/
├── handler.go # Blog route handlers
├── list.html # Blog post listing template
├── detail.html # Individual blog post template
└── components/ # Blog-specific components
└── post-card.html
TailwindCSS classes are available throughout the application. Modify src/styles/styles.css
to add custom styles or extend the configuration in src/styles/config.css
.
Build the application for production:
go generate
go build -o app main.go
./app
This project is open source and available under the MIT License.