Skip to content

Pages

Use React components for pages such as /about/, /logos/, or a custom homepage. Docskit wraps them in the shared navbar and footer and applies the site's theme. You control the content and layout between them.

Write guides in content/ when they belong in the documentation sidebar and search. Use pages for standalone routes and homepage to replace /.

Add a page

Create components/about.tsx in your docs project. Each page module must export a default React component:

components/about.tsxTSX
import { Link } from "@pinanek/docskit/link";
import { Metadata } from "@pinanek/docskit/metadata";

export default function AboutPage() {
  return (
    <article className="project-page">
      <Metadata title="About" description="Learn about this project." path="/about/" />
      <h1>About</h1>
      <p>Read the documentation to get started with the project.</p>
      <Link to="/docs/">Documentation</Link>
    </article>
  );
}

Register the route in docskit.config.ts:

docskit.config.tsTypeScript
pages: {
  "/about/": "./components/about.tsx",
},

Module paths are relative to the docs project. The component above renders at /about/, outside the documentation sidebar layout.

Routes start and end with /. Each segment uses lowercase letters, numbers, and hyphens. Nested routes such as /about/team/ work too. The homepage, documentation, API reference, and version routes are reserved; use homepage for / and content/ for documentation pages.

Restart pnpm dev after adding or removing routes so Docskit can regenerate the page files.

Replace the homepage

Without a custom component, / renders the documentation overview. To replace it, create components/homepage.tsx with a default React component, then select it separately from pages:

docskit.config.tsTypeScript
homepage: "./components/homepage.tsx",
pages: {
  "/about/": "./components/about.tsx",
},

Use the same component structure as the About page, with Metadata pointing to path="/". The documentation overview remains available at /docs/.

For a complete implementation, see the custom homepage example or this site's components/homepage.tsx.

Registering a route does not add it to the navbar or footer. Set links to choose the navbar links:

TypeScript
links: [
  { label: "Documentation", href: "/docs/" },
  { label: "About", href: "/about/" },
],

For a logo download page registered at /logos/, add a footer link:

TypeScript
footerLinks: [{ label: "Logos", href: "/logos/", icon: "Images" }],

Inside a React page, use the package's Link for internal navigation. It works with the configured deployment base path. See Navigation and links for more examples.

Set metadata

Include Metadata in each page with its title, description, and route. It generates the document title, canonical URL, and social metadata. Omitted values fall back to the site settings.

Pass the route without the deployment base path, such as path="/about/". Docskit adds basePath when building the URL.

Style the page

Add a stylesheet to the config:

docskit.config.tsTypeScript
styles: ["./styles/pages.css"],

Create the selected file and scope its rules to your page's class:

styles/pages.cssCSS
.project-page {
  max-inline-size: 70ch;
  margin-inline: auto;
  padding: 3rem 1.5rem;
}

Custom styles load after the built-in styles. Use the theme tokens described in Components and styles for colors and typography.

This site's Logos page uses components/logos.tsx and a stylesheet to show light and dark previews with SVG download links.

Build and check

From your docs project, run pnpm check to check the components and config. Start pnpm dev and open each route. Check navigation, both themes, and narrow screens. Run pnpm build and pnpm preview to inspect the static output before deployment.

The homepage and standalone pages are shared across documentation versions. Next and archive routes redirect to the shared pages under the site's main base path. Standalone pages are built as static HTML and are not included in documentation search.