Notes on Portable Static Hosting

How Klaudia's Blog keeps links, feeds, search, and dev previews consistent at blog.klaudia.pics (or any basePath).

On this page (2)

Hosting a static blog cleanly—whether on a dedicated subdomain like https://blog.klaudia.pics or under a subpath—works best when every link, asset, and feed URL flows through one configuration source.

Centralized URL helpers #

Instead of sprinkling string concatenation across templates, the engine passes a urls helper built from siteUrl and basePath:

src/engine/config.mjs js
export function createUrlHelpers(config) {
  const base = normalizeBasePath(config.basePath);
  const origin = String(config.siteUrl).replace(/\/+$/, "");

  function pathFor(subpath = "/") {
    const clean = subpath.startsWith("/") ? subpath : `/${subpath}`;
    return clean === "/" ? `${base}/` : `${base}${clean}`;
  }

  function fullUrl(subpath = "/") {
    return `${origin}${pathFor(subpath)}`;
  }

  return { base, origin, pathFor, fullUrl };
}

Checklist for static deploys #

  • Completed: Keep stylesheets, scripts, and favicon paths rooted cleanly at /assets/...
  • Completed: Generate canonical <link> and RSS <guid> tags with https://blog.klaudia.pics/...
  • Completed: Serve the local dev preview at / matching production routes

Tip

Because basePath defaults to "/" in klaudia.config.mjs, changing siteUrl or moving to a subpath later updates every HTML page, feed, and sitemap in a single rebuild.