Welcome to Fragmentor v4. Still working in v3?Switch to v3
  1. Docs
  2. Build
documents/about.yml
_type: Page
title: About us
hero:
_type: Hero
heading: null
footer:
_ref: 79ead044
  1. Source
  2. Decode
  3. Validate
  4. Link
  5. Render Footer
  6. Render Hero
  7. Render Page
  8. Bundle
  9. Write
  10. Merge assets
documents/
about.yml
footer.json

A Page document as written, in YAML. It holds a Hero fragment and a reference to the footer document.

Build process

The build turns every document into a static site. It runs once, when you publish, and is then cached until the next build. Anything that has to be current on every visit, is fetched in the browser (see Integrations).

  • Validate. Every object with a _type is checked against its schema. Problems are reported, and an invalid value falls back to its field's default, so one bad field doesn't drop a page.

  • Render. Each document is matched to a component by _type and filled in with its fields, producing plain HTML.

  • Write. Every rendered page is saved as its own .html file, at a path derived from the document's file path. An index file takes the URL of its folder:

    FileURLOutput
    /documents/index.json//index.html
    /documents/about.json/about/about/index.html
    /documents/blog/index.yml/blog/blog/index.html
    /documents/blog/hello.md/blog/hello/blog/hello/index.html
  • Bundle. Repeated <style>/<script> blocks are deduplicated into shared files.

  • Sitemap. Once the project has its own domain, a sitemap.xml listing every page and a robots.txt are generated.

  • Merge assets. Files in /assets/ are copied into the output as they are, without the /assets prefix. An asset always takes precedence over a generated file with the same path:

    FileURLOutput
    /assets/main.css/main.css/main.css
    /assets/images/logo.png/images/logo.png/images/logo.png
    /assets/integrations/cart.js/integrations/cart.js/integrations/cart.js
    /assets/robots.txt/robots.txt/robots.txt (replaces the generated one)
  • Optimize. Every CSS and JavaScript file is minified (except .min. files). Every PNG, JPEG and WebP shown with <img> is encoded as WebP at a few widths under /_images/, and the <img> gets a srcset so each browser downloads only the size it needs. The first image on a page loads with high priority, the others lazily. The original file stays in place, and an <img> with its own srcset or inside a <picture> is left as you wrote it.