DEV Community

Cover image for Migrating a static HTML site to Astro without changing a single URL
Muhammad Mustafa
Muhammad Mustafa

Posted on

Migrating a static HTML site to Astro without changing a single URL

My site had 50+ handwritten HTML pages with the same header pasted into 51 files. I moved it to Astro in a day.

The one setting that kept every URL identical:

// astro.config.mjs
export default defineConfig({
  build: { format: "preserve" }, // pricing.astro -> pricing.html
  compressHTML: false,
});
Enter fullscreen mode Exit fullscreen mode

Before going live, a parity script compared every page with production: titles, meta, canonical, JSON-LD, headings, body text, links, and images. It showed 0 differences, so I shipped.

Live: https://aisaaswithmustafa.com

Top comments (2)

Collapse
 
jasonguo profile image
Jason Guo •

Running a post-migration parity script for canonicals, JSON-LD, and internal links is such a smart safety net. On our own Astro static/edge build (Duskbloods Archive), locking trailingSlash: 'always' plus inlineStylesheets: 'always' and filtering policy routes out of the sitemap kept every URL clean and eliminated render-blocking stylesheet requests from day one.

Collapse
 
aisaaswithmustafa profile image
Muhammad Mustafa •

Thanks! Good points, though only one of them fits this site:

  • trailingSlash 'always': my pages were already indexed with .html URLs, so I kept build.format 'preserve'. Moving to slash URLs would change every address Google already knows. Instead, the build adds 301s from the no-.html and folder versions to the one canonical URL.
  • inlineStylesheets: it only affects CSS that Astro bundles. My pages link one prebuilt Tailwind file (about 50 KB), so the setting would not change anything here. I would also rather keep that file cached across pages than inline it on every page. The only CSS I inline is the small shared footer.
  • Sitemap: agreed. The thank-you page is noindex and stays out of the sitemap.

Did inlining CSS make a noticeable difference to your LCP?