Skip to main content
In this tutorial, you’ll build a simple blog with pages, a layout, and styling. Server-rendered websites are great for content sites, blogs, and applications where SEO matters. The server generates complete HTML pages, which makes your site fast to load and easy for search engines to index.

Step 1: Create the Project

Open http://localhost:8080 to see the default page.

Step 2: Update the Layout

Edit views/layouts/main.html:

Step 3: Create a Blog Post Handler

Create handler/posts.go:

Step 4: Create Post Views

Create views/pages/posts.html:
Create views/pages/post.html:

Step 5: Add Routes

Update app/web/routes.go:

Step 6: Add Styling

Update assets/css/style.css:

Step 7: Test It

Restart the server and browse:
  • http://localhost:8080/ - Post list
  • http://localhost:8080/posts/1 - Single post
  • http://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