feat(seo): real metadata, JSON-LD, robots.txt and a build-time sitemap

index.html advertised nothing: no title, no description, no Open Graph, no canonical. The head now carries both theme-color values, an OG block with an absolute 1200x1600 image, a Twitter card and a Person JSON-LD block with sameAs and a PostalAddress. src/data/site.ts holds the canonical origin; generate-sitemap.ts writes dist/sitemap.xml from navPaths plus the project list (10 urls) and fails the build if dist/index.html no longer contains siteUrl, because an HTML head cannot import TypeScript and the origin is therefore written twice by hand. Chained into pnpm build so dist/ is complete before the deploy workflow uploads it.
This commit is contained in:
dong.nguyen committed 2026-10-18 23:45:39 +07:00
1 parent a5a7eb6b31
commit 0c4aea32b5
5 files changed
+117 -3

No files matched your search

+63 -2
View File
@@ -2,9 +2,70 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>portfolio</title> <title>Nguyễn Đông — Senior Software Engineer</title>
<meta
name="description"
content="Portfolio of Nguyễn Đông, a Senior Software Engineer in Ho Chi Minh City working on distributed systems, logistics automation, computer vision and practical AI in Java, Go and TypeScript."
/>
<meta name="author" content="Nguyễn Đông" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://cv.vugado.com/" />
<meta name="theme-color" content="#151914" media="(prefers-color-scheme: dark)" />
<meta name="theme-color" content="#f6f5f2" media="(prefers-color-scheme: light)" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Nguyễn Đông — Senior Software Engineer" />
<meta property="og:title" content="Nguyễn Đông — Senior Software Engineer" />
<meta
property="og:description"
content="Distributed systems, logistics automation, computer vision and practical AI — SAP Lab Vietnam, Lazada, and a logistics digital-twin platform."
/>
<meta property="og:url" content="https://cv.vugado.com/" />
<meta property="og:locale" content="en_US" />
<meta property="og:locale:alternate" content="vi_VN" />
<meta property="og:image" content="https://cv.vugado.com/profile-photo.webp" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="1600" />
<meta property="og:image:alt" content="Portrait of Nguyễn Đông" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Nguyễn Đông — Senior Software Engineer" />
<meta
name="twitter:description"
content="Distributed systems, logistics automation, computer vision and practical AI — SAP Lab Vietnam, Lazada, and a logistics digital-twin platform."
/>
<meta name="twitter:image" content="https://cv.vugado.com/profile-photo.webp" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Person",
"name": "Nguyễn Đông",
"alternateName": "Dong Nguyen",
"jobTitle": "Senior Software Engineer",
"url": "https://cv.vugado.com/",
"email": "mailto:nguyendong_bkdn@yahoo.com",
"image": "https://cv.vugado.com/profile-photo.webp",
"sameAs": [
"https://github.com/dong-nz",
"https://www.linkedin.com/in/dong-nz"
],
"knowsAbout": [
"Distributed systems",
"System architecture",
"Computer vision",
"AI / ML applications"
],
"address": {
"@type": "PostalAddress",
"addressLocality": "Ho Chi Minh City",
"addressCountry": "VN"
}
}
</script>
<script> <script>
(function () { (function () {
try { try {
+2 -1
View File
@@ -5,11 +5,12 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc -b && vite build", "build": "tsc -b && vite build && pnpm tsx scripts/generate-sitemap.ts",
"build:resume": "pnpm tsx scripts/generate-resume.ts", "build:resume": "pnpm tsx scripts/generate-resume.ts",
"build:resume-all": "pnpm tsx scripts/generate-resume.ts --lang=en && pnpm tsx scripts/generate-resume.ts --lang=vi", "build:resume-all": "pnpm tsx scripts/generate-resume.ts --lang=en && pnpm tsx scripts/generate-resume.ts --lang=vi",
"build:resume-preview": "pnpm tsx scripts/generate-resume.ts --preview", "build:resume-preview": "pnpm tsx scripts/generate-resume.ts --preview",
"lint": "oxlint", "lint": "oxlint",
"sitemap": "pnpm tsx scripts/generate-sitemap.ts",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
+4
View File
@@ -0,0 +1,4 @@
User-agent: *
Allow: /
Sitemap: https://cv.vugado.com/sitemap.xml
+44
View File
@@ -0,0 +1,44 @@
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { siteUrl } from '../src/data/site.js';
import { navPaths } from '../src/data/navigation.js';
import { projects } from '../src/data/projects.js';
const ROOT = resolve(import.meta.dirname, '..');
const distDir = join(ROOT, 'dist');
// Run after `vite build`: the sitemap is a build artifact, and the guard below can
// only compare against a head that has already been produced.
if (!existsSync(distDir)) {
console.error(`dist/ not found — run \`pnpm build\` before \`pnpm sitemap\`.`);
process.exit(1);
}
// index.html carries the canonical origin as static markup; site.ts carries it as data.
// A mismatch means one of the two was edited without the other.
const indexHtml = readFileSync(join(distDir, 'index.html'), 'utf-8');
if (!indexHtml.includes(siteUrl)) {
console.error(
`Canonical origin mismatch: index.html does not contain "${siteUrl}". ` +
`Update the canonical/og:url/theme-color block in index.html or src/data/site.ts.`
);
process.exit(1);
}
const lastmod = new Date().toISOString().slice(0, 10);
// navPaths is the six bar routes; the seventh route (/projects/:id) is enumerated
// from the project data, so a new project lands in the sitemap automatically.
const locations = [
...navPaths.map((path) => `${siteUrl}${path}`),
...projects.map((project) => `${siteUrl}/projects/${project.id}`),
];
const entries = locations
.map((loc) => ` <url>\n <loc>${loc}</loc>\n <lastmod>${lastmod}</lastmod>\n </url>`)
.join('\n');
const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${entries}\n</urlset>\n`;
writeFileSync(join(distDir, 'sitemap.xml'), xml);
console.log(`sitemap.xml generated at ${join(distDir, 'sitemap.xml')} (${locations.length} urls)`);
+4
View File
@@ -0,0 +1,4 @@
/** Canonical origin. Every absolute URL the site publishes derives from this one value. */
export const siteUrl = 'https://cv.vugado.com'
export const siteName = 'Nguyễn Đông — Senior Software Engineer'