Home
Integration

Embedding in Existing Sites

Add sourcey docs as a subfolder in your existing website.

Sourcey's output is static HTML that can be dropped into any existing website's public directory. This is how sourcey.com itself works: these docs are built with sourcey and served from /docs/ alongside the Astro marketing site.

Subfolder deployment

Build the output directly into your site's public directory:

sourcey build -o ./public/docs

Your existing site framework (Astro, Next.js, Hugo, plain Nginx) serves the public/ directory as static files. The sourcey output at /docs/ is completely self-contained: its own CSS, its own JS, its own search index. No conflicts with your main site's styles or scripts.

Build script integration

Add a build script to your package.json:

{
  "scripts": {
    "build:docs": "cd docs && npx sourcey build -o ../public/docs"
  }
}

This assumes your sourcey config and markdown live in a docs/ subdirectory. Adjust paths to match your project layout.

Embeddable output

For iframe embedding, use the --embed flag. This strips the <html>, <head>, and <body> wrappers, producing bare content suitable for injection into an existing page.

sourcey build --embed -o ./embed
Warning

Embedded output expects its CSS and JS files to be served from the same directory. Make sure the output directory is accessible at the path the iframe src points to.

Real-world example

This documentation site is itself built with sourcey. The setup:

  1. A docs/ directory in the sourcey.com repo contains sourcey.config.ts and all markdown files
  2. npm run build:docs runs sourcey build -o ../public/docs
  3. The Astro site serves public/docs/ as static files at /docs/
  4. The "Docs" link in the navbar points to /docs/

The marketing site and the documentation site are independently built and independently styled. They share a URL but nothing else.