DEV Community

InUterr0
InUterr0

Posted on

How We Built a Construction Company Website with Gatsby and Express

When my team at a Swedish construction company needed a new website, we decided to go with Gatsby for the frontend and Express for serving pre-built pages. Here's what we learned building totalbyggarna.se — a site with 2000+ pages.

Why Gatsby for a Construction Site?

You might wonder why a construction company needs a static site generator. The answer is SEO. We needed to rank for thousands of location-based keywords across Stockholm and Nynäshamn.

Gatsby's build-time rendering gave us:

  • Fast page loads — sub-second on mobile
  • Perfect Lighthouse scores — consistently 95+ across all metrics
  • Programmatic page generationgatsby-node.js creates pages from data

The Architecture

Gatsby (build) → static HTML in /public → Express server → Railway hosting
                                              ↑
                                    Cloudflare CDN + SSL
Enter fullscreen mode Exit fullscreen mode

We pre-build everything with Gatsby, then serve the static files through a lightweight Express server (serve-prebuilt.js). This approach means:

  1. Zero server-side rendering at request time — just file serving
  2. Instant deploys — push to GitHub, Railway auto-deploys
  3. Easy redirects — Express handles 301s for SEO migrations

Handling 2000+ Pages

The biggest challenge was build time. With 2000+ pages, Gatsby builds took a while. Our solution:

  • Incremental builds where possible
  • Pre-built HTML editing for quick content updates (skip full rebuild)
  • Trailing slash consistencytrailingSlash: 'always' in gatsby-config

SEO Results

After launching, we saw:

  • DR 18 (up from 0) in 3 months
  • 4,200 monthly organic visits
  • Health Score 100% on Ahrefs site audit

The combination of fast static pages + proper technical SEO + location-based content strategy worked well for a local construction business.

Key Takeaways

  1. Static site generators aren't just for blogs — they work great for business sites with many pages
  2. Pre-building HTML and serving through Express is simpler than SSR
  3. Cloudflare in front of Railway gives you the best of both worlds
  4. Don't underestimate the SEO value of fast page loads

If you're building a website for a local service business, consider this stack. Check out the result at totalbyggarna.se — a Swedish construction company site running on Gatsby + Express.


Have you built business websites with Gatsby or similar SSGs? I'd love to hear about your experience in the comments!

Top comments (0)