diff --git a/projects/site/eleventy.config.js b/projects/site/eleventy.config.js
index 665febb926..9c6517d87d 100644
--- a/projects/site/eleventy.config.js
+++ b/projects/site/eleventy.config.js
@@ -4,7 +4,7 @@ import { EleventyRenderPlugin, IdAttributePlugin } from '@11ty/eleventy';
import EleventyPluginVite from '@11ty/eleventy-plugin-vite';
import litPlugin from '@lit-labs/eleventy-plugin-lit';
-import { BASE_URL } from './src/_11ty/layouts/common.js';
+import { BASE_URL } from './src/_11ty/layouts/metadata.js';
import {
ELEMENTS_PAGES_BASE_URL,
ELEMENTS_REPO_BASE_URL,
@@ -16,6 +16,7 @@ import {
} from './src/_11ty/utils/env.js';
import { searchPlugin } from './src/_11ty/plugins/search.js';
import { llmsTxtPlugin } from './src/_11ty/plugins/llms-txt.js';
+import { sitemapPlugin } from './src/_11ty/plugins/sitemap-xml.js';
import { elementLoaderTransform } from './src/_11ty/transforms/element-loader.js';
import { anchorGeneratorTransform } from './src/_11ty/transforms/anchor-generator.js';
import { htmlMinifyTransform } from './src/_11ty/transforms/html-minify.js';
@@ -104,8 +105,6 @@ export default function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({ '../themes/dist/bundles': 'local-bundles/themes' });
eleventyConfig.addPassthroughCopy({ '../styles/dist/bundles': 'local-bundles/styles' });
- eleventyConfig.addPassthroughCopy('src/robots.txt');
-
// Configure Lit SSR plugin for web components
eleventyConfig.addPlugin(litPlugin, {
mode: 'worker',
@@ -174,6 +173,11 @@ export default function (eleventyConfig) {
eleventyConfig.addPlugin(llmsTxtPlugin);
}
+ // https://www.sitemaps.org
+ if (process.env.ELEVENTY_RUN_MODE === 'build') {
+ eleventyConfig.addPlugin(sitemapPlugin);
+ }
+
// Set custom markdown library
eleventyConfig.setLibrary('md', markdown);
diff --git a/projects/site/package.json b/projects/site/package.json
index 796e5fd5eb..e623f7f987 100644
--- a/projects/site/package.json
+++ b/projects/site/package.json
@@ -63,6 +63,10 @@
"PAGES_BASE_URL": {
"external": true,
"default": "/elements/"
+ },
+ "ELEMENTS_SITE_URL": {
+ "external": true,
+ "default": "https://nvidia.github.io"
}
}
},
diff --git a/projects/site/public/robots.txt b/projects/site/public/robots.txt
index 6f27bb66a3..d5dad0d0d0 100644
--- a/projects/site/public/robots.txt
+++ b/projects/site/public/robots.txt
@@ -1,2 +1,6 @@
User-agent: *
-Disallow:
\ No newline at end of file
+Allow: /
+Disallow: /assets/
+Disallow: /.pagefind/
+
+Sitemap: https://nvidia.github.io/elements/sitemap.xml
\ No newline at end of file
diff --git a/projects/site/src/_11ty/layouts/common.js b/projects/site/src/_11ty/layouts/common.js
index 8c3b43ce77..b75e6509e4 100644
--- a/projects/site/src/_11ty/layouts/common.js
+++ b/projects/site/src/_11ty/layouts/common.js
@@ -1,29 +1,32 @@
/* eslint-env node */
/* global process */
-import { join } from 'node:path';
-import { ELEMENTS_PAGES_BASE_URL, ELEMENTS_PLAYGROUND_BASE_URL, ELEMENTS_REPO_BASE_URL } from '../utils/env.js';
-
-export const BASE_URL = join('/', process.env.PAGES_BASE_URL ?? '', '/');
+import { ELEMENTS_PLAYGROUND_BASE_URL, ELEMENTS_REPO_BASE_URL } from '../utils/env.js';
+import { escapeAttr, resolvePageMeta, renderJsonLd, BASE_URL } from './metadata.js';
/**
* This renders the base head element with all the common styles and scripts needed for ALL PAGES.
* Page specific resources should not be placed here.
*/
-export const renderBaseHead = data => /* html */ `
+export const renderBaseHead = data => {
+ const meta = resolvePageMeta(data);
+ const ogType = meta.url === '/' ? 'website' : 'article';
+ return /* html */ `