Deploy to Netlify ¶
Netlify offers continuous deployment, serverless functions, form handling, and a powerful CDN. It’s excellent for teams and sites that need more than just static hosting.
Prerequisites ¶ #
- A Netlify account (free tier available)
- Your markata-go site in a Git repository (GitHub, GitLab, or Bitbucket)
Cost ¶ #
| Tier | Bandwidth | Build Minutes | Forms | Price |
|---|---|---|---|---|
| Free | 100 GB/mo | 300 min/mo | 100/mo | $0 |
| Pro | 1 TB/mo | 25,000 min/mo | Unlimited | $19/mo |
| Business | 1 TB/mo | 25,000 min/mo | Unlimited | $99/mo |
The free tier is generous enough for most personal and small business sites.
Method 1: Git Integration (Recommended) ¶ #
Step 1: Connect Repository ¶ #
- Log in to Netlify
- Click Add new site > Import an existing project
- Choose your Git provider and authorize Netlify
- Select your repository
Step 2: Configure Build Settings ¶ #
Enter these settings:
| Setting | Value |
|---|---|
| Base directory | (leave empty) |
| Build command | go install github.com/WaylonWalker/markata-go/cmd/markata-go@latest && markata-go build --clean |
| Publish directory | public |
Step 3: Set Environment Variables ¶ #
Click Advanced and add:
| Key | Value |
|---|---|
GO_VERSION |
1.22 |
MARKATA_GO_URL |
https://your-site.netlify.app |
Step 4: Deploy ¶ #
Click Deploy site. Netlify will build and deploy your site automatically.
Method 2: netlify.toml Configuration ¶ #
For more control, create netlify.toml in your repository root:
[build]
command = "go install github.com/WaylonWalker/markata-go/cmd/markata-go@latest && markata-go build --clean"
publish = "public"
[build.environment]
GO_VERSION = "1.22"
MARKATA_GO_URL = "https://your-site.netlify.app"
# Production context
[context.production]
environment = { MARKATA_GO_URL = "https://example.com" }
# Deploy previews (automatic for PRs)
[context.deploy-preview]
command = "go install github.com/WaylonWalker/markata-go/cmd/markata-go@latest && markata-go build"
# Branch deploys
[context.branch-deploy]
command = "go install github.com/WaylonWalker/markata-go/cmd/markata-go@latest && markata-go build"
# Security and caching headers
[[headers]]
for = "/*"
[headers.values]
X-Frame-Options = "DENY"
X-Content-Type-Options = "nosniff"
Referrer-Policy = "strict-origin-when-cross-origin"
[[headers]]
for = "/static/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.html"
[headers.values]
Cache-Control = "public, max-age=0, must-revalidate"
# Redirects
[[redirects]]
from = "/old-path/*"
to = "/new-path/:splat"
status = 301
Method 3: CLI Deployment ¶ #
Deploy manually using the Netlify CLI:
# Install CLI
npm install -g netlify-cli
# Login
netlify login
# Initialize project (first time)
netlify init
# Build your site
markata-go build --clean
# Deploy preview
netlify deploy --dir=public
# Deploy to production
netlify deploy --dir=public --prod
Custom Domain Setup ¶ #
Step 1: Add Domain in Netlify ¶ #
- Go to Site settings > Domain management
- Click Add custom domain
- Enter your domain (e.g.,
example.com)
Step 2: Configure DNS ¶ #
Option A: Use Netlify DNS (Recommended)
- Click Set up Netlify DNS for your domain
- Update your domain registrar’s nameservers to Netlify’s:
dns1.p01.nsone.net dns2.p01.nsone.net dns3.p01.nsone.net dns4.p01.nsone.net
Option B: External DNS
Add these records at your DNS provider:
For apex domain:
Type: A
Name: @
Value: 75.2.60.5
For www subdomain:
Type: CNAME
Name: www
Value: your-site.netlify.app
Step 3: Enable HTTPS ¶ #
Netlify automatically provisions Let’s Encrypt certificates. Go to Domain management > HTTPS and click Verify DNS configuration.
Step 4: Update Configuration ¶ #
Update your markata-go.toml:
[markata-go]
url = "https://example.com"
And your netlify.toml:
[context.production.environment]
MARKATA_GO_URL = "https://example.com"
Deploy Previews ¶ #
Netlify automatically creates preview deployments for pull requests. Each PR gets a unique URL like:
https://deploy-preview-123--your-site.netlify.app
To customize preview behavior, add to netlify.toml:
[context.deploy-preview]
command = "go install github.com/WaylonWalker/markata-go/cmd/markata-go@latest && markata-go build"
[context.deploy-preview.environment]
# Leave MARKATA_GO_URL empty to use Netlify's preview URL
Forms (No Backend Required) ¶ #
Netlify can handle form submissions without a backend:
<form name="contact" method="POST" data-netlify="true">
<input type="hidden" name="form-name" value="contact" />
<input type="text" name="name" required />
<input type="email" name="email" required />
<textarea name="message" required></textarea>
<button type="submit">Send</button>
</form>
Form submissions appear in Site settings > Forms.
Serverless Functions ¶ #
Add serverless functions in netlify/functions/:
// netlify/functions/hello.js
exports.handler = async (event, context) => {
return {
statusCode: 200,
body: JSON.stringify({ message: "Hello from Netlify Functions!" })
};
};
Access at /.netlify/functions/hello.
Troubleshooting ¶ #
Build Fails: Go Not Found ¶ #
Ensure GO_VERSION is set in environment variables:
[build.environment]
GO_VERSION = "1.22"
Build Timeout ¶ #
Free tier has a 15-minute build limit. Optimize your build:
[build]
command = """
if [ ! -f $HOME/go/bin/markata-go ]; then
go install github.com/WaylonWalker/markata-go/cmd/markata-go@latest
fi
markata-go build --clean
"""
Assets Not Loading ¶ #
Check your site URL configuration:
# View current config
netlify env:list
# Set production URL
netlify env:set MARKATA_GO_URL https://example.com
Deploy Preview URL Issues ¶ #
For deploy previews, let Netlify handle the URL:
[context.deploy-preview.environment]
# Don't set MARKATA_GO_URL - let Netlify use the preview URL
Custom Headers Not Applied ¶ #
Ensure netlify.toml is in your repository root (not in a subdirectory).
Performance Optimization ¶ #
Enable Asset Optimization ¶ #
In Site settings > Build & deploy > Post processing:
- Enable Pretty URLs
- Enable Asset optimization (minify CSS/JS)
- Enable Prerendering
Configure Caching ¶ #
[[headers]]
for = "/static/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.xml"
[headers.values]
Cache-Control = "public, max-age=3600"
Next Steps ¶ #
- Netlify Docs - Official documentation
- Configuration Guide - Customize your markata-go site
- Feeds Guide - Set up RSS and Atom feeds