Appearance
Migrate step by step
Move a website to Foliwake one section at a time. Your CDN sends one part of the host, for example www.example.com/news/*, to the Foliwake delivery service, and everything else to your current CMS, as before. Readers see one site. When the section works, move the next one. If something goes wrong, take the section's paths out of the CDN rule and the CMS serves them again.
When to use it
- A site is too large, or too busy, to move in one go.
- One part of it changes often and would gain the most from previews, page-by-page publishing and separately released frontend code: news, a help centre, documentation.
- You want to try Foliwake on real traffic before you decide about the rest.
You need a CDN in front of the host that can send requests to different servers by path. Both examples below do. If the whole site moves at once, you do not need this guide: point the host at the delivery service.
How it fits
Nothing in Foliwake depends on the host being shared. The delivery service never reads the CMS, sets no cookies, and clears only its own entries from a cache (every cache tag it sends starts with fw:<site>:). The CMS does not know Foliwake is there.
1. Choose the section
A good first section:
- lives under one path prefix, such as
/news; - has pages that look alike, so a few blocks and one template cover them;
- links mostly to itself and to a few fixed pages of the old site (home, about, contact);
- has no forms that post to its own paths (see limits).
Give the pages the same addresses they have today. A page's address is its path in front matter, or a path mapping of its source: path: /news/a-new-bridge serves www.example.com/news/a-new-bridge.
2. Decide the paths the CDN routes
| Path | What it is |
|---|---|
/news and /news/* | The section's pages, and their .plain.html bodies if apps embed them. |
/news/_fw/* | The section's code and pictures, with the asset prefix of step 3. |
/news/sitemap.xml | The section's sitemap, with sitemap.target. |
/news/query-index.json | A query index, if the section's code uses one (any target you choose under /news). |
Write the rule as two patterns, /news and /news/*. A single /news* also catches /newsletter.
Without an asset prefix, pages name their code at /code/… and pictures at /media/… at the root of the host. That works only if the CMS uses neither path; route both to the delivery service then. Many CMSs serve their own files under /media, so set the prefix.
3. Delivery service settings
In the site's frontend code, next to access.yaml, site.yaml holds the settings that travel with each code release (reference: site settings):
yaml
# site.yaml
version: 1
delivery:
assetPrefix: /news/_fw # code and pictures under the section's own path
links:
external: # pages the CMS serves on the same host
- /
- /about
- /contact
- /shop/**The prefix ends in a segment that starts with _, which no page path can have, so it never hides a page. The delivery service answers the default form too, so the change needs no other setting. It takes effect when that code release goes live; a code rollback takes it back.
The sitemap goes in the section's own path, in query.yaml:
yaml
# query.yaml
version: 1
indices:
news:
include: ["/news/**"]
target: /news/query-index.json
properties: [title, description]
sitemap:
source: news
target: /news/sitemap.xmlIn the site's entry of foliwake.config.json, the public address names the shared host:
json
{
"id": "news",
"liveHosts": ["www.example.com"],
"liveUrl": "https://www.example.com",
"sitemap": { "origin": "https://www.example.com" }
}liveUrlgives every live page its canonical link (see SEO).sitemap.originis the start of every address in the sitemap.liveHostslists the host names the Docker delivery service answers for: theHostthe CDN sends. If the CDN sends its own name for the delivery service, such asnews-origin.example.com, list that name instead. The Cloudflare Worker does not look atHost.
On the Cloudflare Worker, access.yaml decides what anyone may read; without it every page is closed. Open the section:
yaml
# access.yaml
version: 1
allow: ["/news", "/news/**"]4. CDN rules
Cloudflare: Worker routes
Deploy the delivery Worker as in deploy the Cloudflare Worker delivery service, with routes on the shared host instead of a custom domain of its own. In wrangler.delivery.jsonc:
jsonc
{
"routes": [
{ "pattern": "www.example.com/news", "zone_name": "example.com" },
{ "pattern": "www.example.com/news/*", "zone_name": "example.com" }
],
"vars": {
"SITE": "news",
"CACHE_HOST": "www.example.com",
"LIVE_URL": "https://www.example.com"
// TOKEN_ISSUER, TOKEN_PUBLIC_JWK and the rest as in the deploy guide
}
}- Requests on the routes go to the Worker; every other path goes to the CMS as before.
CACHE_HOSTis the host the Worker's cache entries are kept under. It must be in the zone the purge token can purge; the shared host is.- Purges after a publication use the site's Cloudflare purge settings, as in the deploy guide. They name only
fw:news:…tags, so the CMS's cached pages are never cleared by a Foliwake publication.
Amazon CloudFront: two origins, path behaviours
CloudFront has no purge adapter in Foliwake. Pages are kept for a short time instead, so a publication shows within that time.
- Origins. Keep the CMS origin. Add one for the Docker delivery service, for example
news-origin.example.comover HTTPS. Do not forward the reader'sHost; listnews-origin.example.comin the site'sliveHosts. - Behaviours. Add two, before the default one: path patterns
/newsand/news/*, both to the delivery service origin. The default behaviour (*) stays on the CMS. - Settings of both behaviours:
- Allowed methods:
GET, HEAD. - Cache policy: minimum TTL 60 seconds, maximum TTL one year; no cookies and no headers in the cache key; query strings
offsetandlimitonly (the query index uses them). - Origin request policy: none. The delivery service needs no cookies.
- Allowed methods:
Why these numbers: pages come with Cache-Control: public, max-age=0, which asks browsers to check every time. The minimum TTL lets CloudFront keep a page for 60 seconds, so a publication shows within a minute. Code and pictures come with max-age=31536000, immutable: their addresses change when they do, so they are kept for a year. A missing page is kept for the minimum TTL too.
For a change that cannot wait a minute, create an invalidation for /news/*.
5. Headers and Content-Security-Policy
The delivery service sends Content-Type, Cache-Control, ETag, X-Content-Type-Options: nosniff and its cache tags. Headers your CDN adds to every path of the host (HSTS, for example) apply to the section too.
A page has one inline script, the import map of its code. Its hash changes with every code release, so a policy written once into a CDN rule cannot allow it. If your CDN adds a Content-Security-Policy to every path:
- exclude
/newsand/news/*from that rule, and - set
delivery.csp: strictinsite.yaml. Live pages then send their own policy, with the hash of their import map, allowing scripts, styles and requests from the host only.
It is off by default: a strict policy blocks scripts, styles and fonts from other hosts that the section's code may load. Test it in the preview of a branch first.
6. Header and footer
The shared header and footer belong to the CMS, and Foliwake has no place in the page frame to insert another system's markup. Choose one:
- Build them in the site code (recommended for the first section). A page template with the header and footer markup and styles, applied to the section's pages. Fast and stable; when the CMS's header changes, change the template too.
- Load them in the browser. A small script of the site code fetches the header and footer from a CMS path on the same host and inserts them. One more request per page, and the page shifts as they arrive.
- Insert them at the CDN. An edge function that fetches the CMS fragment and writes it into the page. Most work, and specific to one CDN.
7. SEO
- Canonical links. With
liveUrlset (LIVE_URLon the Worker), every live page links<link rel="canonical" href="https://www.example.com/news/…">. A page withlangin its front matter also links itself as itshreflangalternate. - Sitemap. Served at
/news/sitemap.xmlwith addresses onhttps://www.example.com. Add it to the CMS'srobots.txt:Sitemap: https://www.example.com/news/sitemap.xml, and remove the section's pages from the CMS sitemap. - Same addresses. Keep the old paths. Foliwake serves
/news/aonly: no/news/a.htmland no/news/a/. If the old addresses had either, add redirects or rewrites at the CDN. - Redirects for pages that moved or were dropped live at the CDN or in the CMS; Foliwake has none.
8. Links between the old and the new
- From the CMS to the section. Links such as
/news/a-new-bridgekeep working; nothing changes. - From the section to the CMS. Write root paths, such as
/about. Every check (page check, a sync, a preview) warns about a link that matches no page (CONTENT_LINK_UNKNOWN_PATH). List the CMS's paths inlinks.externalofsite.yaml, and the warning remains for real mistakes only. - To sections that will move later. Keep them in
links.externaluntil they move.
9. Cut over, and roll back
- Publish the section in Foliwake: its pages, and the code release with
site.yaml,access.yamlandquery.yaml. - Check the delivery service before any reader can reach it: open a page, a picture under
/news/_fw/media/, the sitemap and a missing page on the delivery service's own address (the Docker origin, or the Worker on a test route). - Add the CDN rule of step 4.
- Clear the CDN's cache for
/newsand/news/*: it may still hold the CMS's pages. - Check from outside:
curl -I https://www.example.com/news/showsCache-Tag: fw:news:…when the delivery service answered.
To roll back, remove the routes (Worker) or the two behaviours (CloudFront) and clear the cache for /news/* again. The CMS serves the section as before, so keep its pages until the new section has run for a while. Nothing in Foliwake changes; the section can go back later.
10. The next section
- Write its pages with their old paths, for example
/guides/…. - Add
/guidesand/guides/*to the CDN rule, and toallowinaccess.yamlon the Worker. - Take its paths out of
links.external.
One Foliwake site can hold several sections. The asset prefix is one per site: with several sections in view, choose one outside them, such as /_fw, and route it too.
Limits
These are the gaps today. Each has a workaround above or at the CDN.
| Limit | What to do |
|---|---|
Only GET and HEAD; anything else answers 405. | Forms post to a CMS path. |
No .html addresses and no trailing slash. | Rewrites or redirects at the CDN. |
| No redirects in Foliwake. | Redirects at the CDN or in the CMS. |
| The missing page is a plain one, kept 60 seconds. | A custom error page at the CDN for /news/*. |
| No place for another system's header and footer. | Step 6. |
| One live host is one site on the Docker delivery service; one Worker serves one site. | One site for all moved sections. |
On the Cloudflare Worker, every page is closed without access.yaml, and the sitemap is always closed. | Open the section in access.yaml; for a public sitemap, serve it from the Docker delivery service or keep the section in the CMS sitemap. |
| No cache clearing for CloudFront and other CDNs. | A short page TTL, and invalidations by hand. |
| Query strings of pages are ignored. | Keep them out of the cache key. |
Values in query indexes are served as stored, and .plain.html bodies keep /media/… addresses. | If a page field in an index holds a picture address, route /media/* too; apps that embed bodies rewrite picture addresses themselves. |
A page links only its own language as hreflang. | Translations are not linked yet. |
