sqzass.git

sqzass

~ A static site generator written in Rust
git clone https://github.com/debuman/sqzass.git

docs/content/deploy/cloudflare-pages.md (1762B)

      1 +++
      2 title = "Cloudflare Pages"
      3 description = "Two settings in the dashboard, and the headers GitHub Pages would not give you"
      4 weight = 40
      5 toc = true
      6 +++
      7 
      8 In the project's build settings:
      9 
     10 | | |
     11 |---|---|
     12 | Framework preset | None |
     13 | Build command | `curl -sSL https://github.com/debuman/sqzass/releases/latest/download/sqzass-x86_64-unknown-linux-musl.tar.gz \| tar xz --strip-components=1 && ./sqzass build` |
     14 | Build output directory | `public` |
     15 
     16 There is no configuration file to write.
     17 
     18 ## This is the host to move to when you need headers
     19 
     20 sqzass is built so nothing depends on host configuration, and this site is on
     21 GitHub Pages specifically to keep that honest. But GitHub Pages serves
     22 everything with `cache-control: max-age=600` and there is no way to change it.
     23 
     24 Cloudflare Pages reads a `_headers` file, so the content-hashed filenames can
     25 finally mean what they are for:
     26 
     27 ```
     28 # static/_headers
     29 /css/*
     30   Cache-Control: public, max-age=31536000, immutable
     31 /js/*
     32   Cache-Control: public, max-age=31536000, immutable
     33 /*
     34   Cache-Control: public, max-age=600
     35 ```
     36 
     37 A year is safe for those two directories precisely because their filenames
     38 change when their contents change. That is the payoff of hashing the name
     39 rather than appending a query string, and it is unavailable on a host that will
     40 not let you set the header.
     41 
     42 Put the file in `static/` and it is copied through untouched.
     43 
     44 ## Redirects
     45 
     46 `_redirects` works the same way, but reach for [`aliases`](@/content/front-matter.md)
     47 in front matter first:
     48 it lives next to the page that moved, it is checked at build time, and it
     49 follows the page to whatever host you use next.
     50 
     51 ## Preview deployments
     52 
     53 `$CF_PAGES_URL` holds the preview address:
     54 
     55 ```bash
     56 ./sqzass build --base-url "$CF_PAGES_URL"
     57 ```