fix(seo): honour SITE_URL for blog canonicals (#933)

A build with a custom SITE_URL failed seo-audit on the blog pages:
generate-blog.mjs hard-coded https://www.bentopdf.com, and the
hand-written blog/author-alam.html carries that origin literally while
generate-i18n-pages.mjs only rewrites top-level pages.

generate-blog.mjs now reads SITE_URL like its sibling scripts, and
enhance-seo-pages.mjs rebases the default origin in dist/blog/*.html
to SITE_URL (dist only, no-op for the default URL) through a small
side-effect-free helper, scripts/site-origin.mjs, covered by
src/tests/site-origin.test.ts.
This commit is contained in:
David Cumps committed 2026-10-21 19:02:45 +00:00
1 parent 4a7dc7675b
commit 3c605eef56
4 files changed
+87 -6

No files matched your search

+2 -1
View File
@@ -3,13 +3,14 @@ import path from 'path';
import { marked } from 'marked';
import { fileURLToPath } from 'url';
import { serializeJsonLd } from './json-ld.mjs';
import { DEFAULT_SITE_URL } from './site-origin.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const POSTS_DIR = path.resolve(__dirname, '../blog/posts');
const BLOG_DIR = path.resolve(__dirname, '../blog');
const SITE_URL = 'https://www.bentopdf.com';
const SITE_URL = (process.env.SITE_URL || DEFAULT_SITE_URL).replace(/\/+$/, '');
const AUTHOR = {
name: 'Alam',
url: `${SITE_URL}/blog/author-alam`,