Step 1: Create the Project
http://localhost:8080 to see the default page.
Step 2: Update the Layout
Editviews/layouts/main.html:
Step 3: Create a Blog Post Handler
Createhandler/posts.go:
Step 4: Create Post Views
Createviews/pages/posts.html:
views/pages/post.html:
Step 5: Add Routes
Updateapp/web/routes.go:
Step 6: Add Styling
Updateassets/css/style.css:
Step 7: Test It
Restart the server and browse:http://localhost:8080/- Post listhttp://localhost:8080/posts/1- Single posthttp://localhost:8080/about- About page
What You Learned
- Creating page handlers
- Using templates with data
- Layouts and partials
- URL parameters in routes
- Styling with CSS
Next Steps
Live Template
Add real-time features
View Engine
Learn more about templates