Appearance
Connect a Google Drive folder
The Google Drive connector (google-drive-markdown) reads Foliwake Markdown files and their images from a Drive folder and all its subfolders. Authors can edit the files in the browser or with Google Drive for desktop. Foliwake only reads the folder: it asks Google for read-only access (drive.readonly) and never changes a file.
This guide uses a site called my-site and a Drive folder called Docs, published under /docs.
What it reads
- Pages: every file whose name ends in
.md. The files use the same Markdown and front matter as local pages. - Images: JPEG, PNG, GIF, WebP and AVIF files that a page references with a relative path, such as
./images/map.png. The path is resolved against the Markdown file in Drive, so the folder layout matters. - Google Docs documents: skipped by default; with
"docs": "read"each document is a page. See Google Docs documents in the folder. - Skipped: Sheets and other Google files, other file types, and any file or folder whose name starts with
.. Skipped files are named as warnings in the server log. - Not followed: Drive shortcuts. Put the file itself into the folder.
Before you start
You need:
- a Google account that can create a Google Cloud project;
- edit access to the Drive folder, so that you can share it;
- admin access to the Foliwake server: you add the key to its environment;
- a site whose
ownspaths leave room for the new source (two sources must not own the same path).
1. Create a Google Cloud project and turn on the Drive API
- Open the Google Cloud console and create a project, for example
my-site-docs. - Go to APIs & Services › Library, find Google Drive API and click Enable.
The connector needs only the Drive API.
2. Create a service account and a key
- Go to IAM & Admin › Service Accounts and click Create service account. Give it a name such as
foliwake-reader. It needs no project roles. - Open the new account, go to Keys › Add key › Create new key, choose JSON and download the file.
- Note the account's e-mail address. It looks like
foliwake-reader@my-site-docs.iam.gserviceaccount.com.
Keep the key file private. Anyone with it can read every folder you share with this account.
Some Google Workspace organisations block service-account keys. If Create new key is refused, ask your Workspace admin, or use the OAuth mode described in other ways to sign in.
3. Share the folder with the service account
In Google Drive, open the Docs folder, click Share, add the service account's e-mail address and choose Viewer. Turn off the notification e-mail; the account has no mailbox.
Viewer is enough. The connector refuses a credential that grants more than read-only access to Drive.
Folders in a shared drive work too. Add the service account to the shared drive as a member (Viewer is enough).
4. Give the key to the server
Foliwake never stores a secret in the site configuration. The site names the key by a name, and the server looks the value up each time it syncs or checks the source. Use FOLIWAKE_GOOGLE_SA_KEY unless you need several keys.
Store it on the server (recommended). The installation's owner uploads the JSON key file once:
sh
foliwake credential set FOLIWAKE_GOOGLE_SA_KEY --from-file my-site-docs-key.json --server https://foliwake.example.comThe command checks that the file is a service-account key and prints the account's e-mail address. The server keeps the key in its data folder (<data>/credentials/, readable by the server only) and never shows it again. The next sync uses it; no restart is needed. Upload a new key the same way to replace it. foliwake credential list shows which names are set and which sources use them.
The Docker image keeps its data in /data, so this works without setup. Another installation needs FOLIWAKE_DATA_DIR (or FOLIWAKE_CREDENTIALS_DIR, a folder of its own) in the server environment; every process that syncs must see the same folder.
Or set an environment variable. A variable of the same name in the server environment wins over a stored value. The value is the whole JSON key on one line. On a server installed with foliwake docker, add it to the instance's .env file (~/.config/foliwake/docker/<name>/.env), above the block that foliwake docker manages:
sh
jq -c . my-site-docs-key.json # prints the key on one linesh
FOLIWAKE_GOOGLE_SA_KEY='{"type":"service_account","project_id":"my-site-docs",…}'Then run foliwake docker update to recreate the container with the new variable (restart does not reread the file).
A name must be upper case. It must not be a system variable such as PATH, start with GIT_ or NODE_, or be one of Foliwake's own settings.
If the key is missing, a sync fails with "credential variable FOLIWAKE_GOOGLE_SA_KEY is not set; set it in the server environment or with foliwake credential set".
5. Add the source
With the CLI, one command checks the source and then saves it. Pass the folder link as you copied it from the browser, or only its ID:
sh
foliwake source add --site my-site --id docs --owns /docs \
--folder "https://drive.google.com/drive/folders/<folder ID>"The command first checks everything without saving. It checks the entry, whether the key is set (and the service account's e-mail address), whether the folder opens, and which files it holds with the page address each would get. Then it asks before it saves. Useful flags:
--subfolder site/en: a folder inside that holds the pages;--mappings rules.json: path mapping rules, checked against the files before saving;--identity front-matter: tie pages by theirid:line instead of the Drive file (defaultfile-id, see page identity);--key NAME: another credential name thanFOLIWAKE_GOOGLE_SA_KEY;--check-only: check and print, save nothing;--yes: save without asking (scripts).
Saving changes the site's settings only. Nothing is fetched until you sync.
You can also add the source in the dashboard (Sources › Add a source, then choose Google Drive folder (Markdown)), or with foliwake site edit --site my-site. The entry looks like this:
json
{
"id": "docs",
"plugin": "google-drive-markdown",
"displayName": "Docs (Google Drive)",
"owns": ["/docs"],
"settings": {
"auth": "service-account",
"folderId": "<folder ID>",
"identity": "file-id"
},
"credentials": { "serviceAccountKey": "FOLIWAKE_GOOGLE_SA_KEY" }
}| Setting | Meaning |
|---|---|
auth | service-account (this guide) or oauth-refresh-token. Required. |
folderId | The ID of the Drive folder. The folder and all its subfolders are read. Required. |
subfolder | Optional. A folder path inside that folder that holds the pages, such as site/en. Names are case-sensitive. Empty means the folder itself. |
identity | How a file is tied to its page: front-matter (default) or file-id. See page identity. Choose it now: it cannot be changed later. |
docs | skip (default) or read: whether Google Docs documents in the folder are pages. read needs identity: file-id. It can be changed on an existing source. |
credentials.serviceAccountKey holds the name from step 4, never the key.
In the dashboard, open the source and use Check connection before the first sync. It shows whether the server can sign in to Google and open the folder.
Map folders to page paths
Without mapping rules, each Markdown file says where it is published with a path: line in its front matter. With mappings, the folder layout decides the address instead, and authors only write title and description.
For a Docs folder like this:
text
Docs/
index.md
guides/
install.md
upgrade.md
drafts/
new-idea.mdthese rules publish index.md at /docs, guides/install.md at /docs/guides/install, and skip the drafts:
json
"mappings": [
{ "match": "drafts/{*}.md", "ignore": true, "note": "work in progress" },
{ "match": "index.md", "path": "/docs" },
{ "match": "{section}/{page}.md", "path": "/docs/{section}/{page}" }
]How rules work:
matchis compared with the file's path inside the folder (or insidesubfolder), one segment per folder level. The last segment is the file name with.md.{name}captures part of one segment.{*}matches without a name.{**}matches any number of whole folders.{lang:en|de}matches exactly one of the listed values.- The first rule that matches wins. Put narrow rules, such as
ignorerules, before wide ones. metadatacan set front matter values from captures, for example"metadata": { "lang": "{lang}" }.- A Markdown file that no rule matches is an error, so every file must have a rule. Add an
ignorerule for files that are not pages. - A captured value used in
pathmust already be a valid path segment: lower-case letters and digits, joined by-or_. It is never lower-cased or changed for you. - Images are not affected. A relative image path is always resolved against the file in Drive.
Folder names written for people can carry the path segment in brackets. The rule {*} [{section}]/{page}.md reads the folder 1. Getting started [start] as section start.
Rules are not part of the dashboard form yet. Pass them to foliwake source add --mappings rules.json, which shows each file's address before it saves, or add them later with foliwake site edit --site my-site. Before you sync, check them against the files the source already has:
sh
foliwake source mappings check --site my-site --source docsIt shows each file's path now and with the rules, files no rule matches, and rules that never match. It reads nothing from Drive and changes nothing.
Page identity
Every page has a stable page ID. The identity setting decides how a Drive file is tied to it.
front-matter (default). Each file names its page with an id: line in its front matter. A file without a valid id is an error. Two files with the same id are an error.
file-id. The Drive file is the page. Files need no id: line; Foliwake gives the page an ID at its first sync and names it after the page path, for example docs-guides-install-<12 hex characters>. An id: line in the file is ignored, with a warning.
With file-id:
Renaming or moving a file keeps the page. Drive keeps the file ID, so the page keeps its ID and history and gets its new path.
Deleting a file and uploading it again creates a new Drive file. If the new file lands at the same place (a rule maps it to the path where the old page is live or in preview) and the old file is gone, the sync connects it to the old page. You see the warning
SOURCE_PAGE_REPLACED. The page keeps its ID, address and live version, and the new text goes live when you publish it.When the sync cannot tell, because the file went to another folder or the old file still exists, it is a new page. To let it feed the published page, run:
shfoliwake page replace --site my-site --path /docs/guides/install --with <Drive file ID>The file ID is in the file's address (
https://drive.google.com/file/d/<file ID>/view), or infoliwake source sync --jsonasnative_id. The command shows its plan and asks before it changes anything. Then sync, preview and publish as usual. See a source file deleted and uploaded again.Two files for one page path (for example a copied folder) are an error that names both files with their IDs and modification times. Delete or move one of them.
Choose identity when you create the source. Changing it later, or changing folderId or subfolder, points the source at a different upstream. Syncing then stops with SOURCE_BINDING_CHANGED, while published pages keep working. To switch, create a new source.
Google Docs documents in the folder
With "docs": "read" (and "identity": "file-id"), a Google Docs document in the folder is a page, read like a Markdown file of the same name: a document ru in lesson/ is the page file lesson/ru.md, so the path rules do not change. Change it in the source's settings; it is not part of the source's binding, so the source keeps its pages. The server's service account needs no new access: it reads documents with drive.readonly.
How a document is written:
- Title is the page title; Subtitle is its description.
- Every Heading 2 is a slide. Its ID is made from its heading text unless the author types one (see slide and answer IDs).
- Paragraphs, bold, italic, lists, links and inserted images carry over. Bold and italic count as you see them: set on the text, or given by the paragraph's style (Format › Paragraph styles). When a style makes a whole heading bold, that is the heading's look, not bold text; a bold word in a heading that is otherwise not bold stays bold. Text in a monospace font (Courier New, Roboto Mono, …) is code: write
sign:2.1that way. - A block is a small form (a table). Its first row is one merged cell, the caption: the block's label in any language of the block definition, or its name, then its variant or argument exactly as after
:::, in parentheses (or after·):Вопрос,Вопрос (directions),Сцена (garden-tools/T1-up). A variant may also be written by its label in any language of the definition:Вопрос (лампы теплицы). Case does not matter. A label that two blocks (or two variants) share is an error; write the name instead. A caption linked to the Sidekick edit address (https://sidekick.foliwake.org/edit?…: the Sidekick browser extension links the caption and ends it with «✎») is read as its text, the link ignored, without the trailing «✎». Any other link stays caption text. - Every other merged row is a field. Its first line is the field's label (in any language of the block definition) or its name, the lines under it are the value. A line in a heading style (Heading 3) is the block's heading, such as a question's prompt, with no label above it. Fields may come in any order.
- Answers follow their label row («Варианты ответа»), one row of two cells each: the answer text, and
☑(correct) or☐([x]/[ ]work too). A second paragraph in the text cell is that answer's explanation. Its ID comes from its text or place. Rows of three cells (ID | answer | mark, as documents uploaded before 20 November 2026 have them) and answers typed as lines in the label's own cell ([x] Корень) are read too. - Layout is free. Font size and colour, shading, borders, column widths, "page break before" on a heading and empty lines are not read.
drive to-docswrites each block as a light form: a small grey caption with a thin rule under it, a pale background and a blue bar on the left, grey labels, each slide on a new page. - A quote is an indented paragraph (Format › Indentation › Increase indent, or ⌘]). Indented paragraphs in a row are one quote. An indented list item or heading stays a list item or heading. Inside a block, a quote field is its own row as before.
- Ordinary tables (no caption row) are tables on the page: the first row is the header, each cell's text is one line. Keep every row as wide as the header.
- Links to the site itself (to its live or preview host) are published as the page's path (
/lessons/x), so they work on every host the page is served from. Links to other sites stay as they are. - The page's fields go in a
pagetable (страница), anywhere in the document, at most one: its first row ispagealone (one merged cell), then one row per field,name | value:exam | • watering_dark • watering_daytime. Bulleted items are a list, an empty cell an empty list, anything else one line of text.titlesets the page title when it differs from the Title paragraph.id,path,templateanddescriptioncannot be set here (the rules give the first three, the Subtitle is the description). The source's rules still give their values; a field in the table wins over the rule's. - A slide's metadata goes in a
sectiontable (раздел) right before the slide's Heading 2:sectionalone in the first row, thenkey | valuerows (question | 1/1). It becomes the slide's:::section-metadata. A section table anywhere else is an error. - The older block table of two columns (
block|question directions, thenlabel | valuerows, answers as lines starting with[x]/[ ]) is still read. - Images in an image field are inserted pictures, each on its own line; the line under an image is its caption. The alt text is the image's alt text in Docs (right-click › Alt text).
- Small pictures inside text (a plant label in a caption) may stand in the text of a text, quote or list field, an answer or an answer's explanation: insert the picture in the line, next to the text. It is published like a picture in ordinary text, with its alt text, at its place in the line. Not allowed: a picture in a block's heading line, in a field whose definition says
format: code, and a text-field line that is only a picture (that is an image field's picture: put it there, or add text). - One tab per document, one document per language (
ru,en,ka). Suggestions are not published until they are accepted; comments are not read.
Only three things an author types pass unescaped: an ID ({#id} at the end of a heading or an answer, or an answer's ID cell; optional, see below), an answer's mark ([x] / [ ], ☑ / ☐), and code (monospace text). Everything else is text, so a document cannot inject Markdown or HTML.
Slide and answer IDs
Every slide and every answer has an ID: links to a slide (…/lesson#ruka-podnyata), the blocks' own logic (which arrow an answer about directions is) and the check of a moved lesson use it. As in Adobe's Edge Delivery Services, authors usually do not write it: a slide's ID is made from its heading text. An ID comes from, in this order:
{#id}typed at the end of the heading or answer. It is optional; write it to keep an ID that the text would not give (an old link, a fixed name the site's code uses). Blocks whose answer IDs carry meaning and have no form yet (tap,rig-set,sequence,pose,kit,apply) still need it.- A stored ID (a named range
fw1:slide:intro/fw1:opt:lefton the line end), whichdrive to-docsanddrive stamp-idswrote before 21 November 2026. They are no longer written by default, but a document that has them keeps their IDs. A stored ID the reader cannot use (two on one heading, the same slide ID twice, one that points at no heading or answer any more) is a warning, never an error. - Otherwise a slide gets the slug of its heading text: lower case, Cyrillic and Georgian written in Latin letters, punctuation, emoji and symbols left out, words joined by
-, everything before the first letter left out, at most 56 characters (cut after a whole word): «🏷️ Лейка полна — поливайте» →leyka-polna-polivayte, «2.1 Грядки» →gryadki. A heading without a letter getsslide. The second slide with the same slug gets-2, the third-3, in document order; a slug never takes an ID typed on another heading of the page. (Edge Delivery Services keeps non-Latin letters and numbers repeats from-1; Foliwake writes ASCII so addresses read the same everywhere, and its IDs must start with a letter.) - An answer of a block that requires IDs gets the ID whose label in the block definition (
idValues) is its text («Слева» →left, any language, case and punctuation ignored), else its place:a1,a2, … A variant that needs certain answers (variantIds, such as the four greenhouse lamps) uses those labels only in itself, and its page gets a warning naming the answers it needs when the answers differ.
Editing a slide's heading changes its ID, and a link to the old ID (…#leyka-polna) stops working; so does moving a slide above another one with the same heading text. To keep the old ID, add it at the end of the heading: Лейка полна, стоп {#leyka-polna}. A slide ID that changed is not reported yet (see limitations).
A block with a wrong label, a field given twice, a row of the wrong shape or an answer without ☑ / ☐ is an error of that row: the sync is refused with a message that names the document, the table row and the field, and the selected snapshot stays.
A document and a Markdown file with the same name in one folder are an error of both pages: neither wins. Move one of them out of the folder.
Moving a Markdown lesson to a document
foliwake drive to-docs moves one lesson and keeps its page (the same page ID, address, history and progress keys). Run it on the computer that has the folder in Drive for desktop, with the site's built code folder:
- Dry run.
foliwake drive to-docs --file "<Drive>/…/lesson/ru.md" --code <site>/buildwrites the lesson as a document, reads it back and checks that it compiles to the same page; it writesru.docxto look at. Nothing leaves the computer. Slide headings show no{#id}: a slide's ID becomes the slug of its heading (the check notes each heading whose ID changes; a link to the old ID is a difference). An answer whose text or place would not give it its ID gets it typed at the end (Слева {#left}), as an author would type it.--stamp-idswrites no ID and stamps the lesson's IDs as named ranges after the upload instead (the behaviour before 21 November 2026). - Upload. Create an OAuth client of type "Desktop app" in your Google Cloud project, set
FOLIWAKE_GOOGLE_OAUTH_CLIENT_IDandFOLIWAKE_GOOGLE_OAUTH_CLIENT_SECRET, and add--upload --folder <ID of the lesson/ folder>. You allow access once in the browser (drive.file: the tool sees only files it creates). The uploaded document is read back and checked again; every difference is listed. With--stamp-idsthe lesson's slide and answer IDs are first stamped on it as named ranges (one change, refused if the document was edited since it was read), and--doc <document ID> --stamp-idsstamps what a document still lacks. Google re-encodes inserted pictures, so pictures are compared by their pixels: the same picture with other bytes is reported as re-encoded, not as a difference. The page then publishes the document's bytes, so the picture's media name (sha256-…) changes once; what readers see does not. Add--save-images <dir>to look at the pictures as Google serves them. - Commit. Add
--doc <document ID> --commit --archive "<Drive>/Lessons/archive/<lesson>/lesson"(a folder outside the source). The Markdown file is moved there. The next sync finds the document at the same page file and replaces the page (SOURCE_PAGE_REPLACED). - Roll back by moving the Markdown file back and removing the document from the folder; the next sync replaces the page again, with the same page ID.
Move a whole folder
foliwake drive to-docs --tree moves every page of a source's folder in one language to documents in a new folder tree. The old tree is only read. The new tree is read by a second source, beside the old one, with every page under a path prefix such as /v2. The old source keeps its pages, addresses and history, so the live site does not change while you check the documents. An app that reads the pages can switch to the prefix when you are ready, and switch back the same way.
Save the source's rules to a file. The tool selects files the same way a sync does:
shfoliwake site show --site my-site --json | jq '.entry.sources[] | select(.id == "lessons")' > rules.jsonDry run. Pass the local folder the source reads (its folder plus
subfolder) and the prefix:shfoliwake drive to-docs --tree "<Drive>/Lessons/Georgia" --mappings rules.json --code <site>/build --lang ru \ --out ./to-docs --path-prefix /v2 --site-url https://lessons.example.orgA file moves when a rule makes it a page in
--lang.--include lesson,handbooklimits the move to some kinds (the rule'skindvalue; a page without one is alesson). Pass the site's address with--site-urlwhen pages link to other pages of the site (/lessons/x): the document links to that address, and the reader turns it back into the path. Each page is written as a Word file under--out, in the same folders, and checked like one lesson, with the values its rule gives it (country,topic,exam…). Its full report is<name>.report.txtbeside the Word file. The summary lists, by kind, the pages that are ok, that differ, and that the document convention cannot carry, with the first reason, and counts every reason across the pages. Two differences are accepted and only noted: a heading whose ID differs (in Google Docs a slide's ID is the slug of its heading text; a link to the old ID is still a difference), and a line break inside a paragraph becomes a space. It also lists the files that stay only in the old tree: other languages, other kinds, and files no rule fits. The exit status is 1 unless every page is ok.With
--path-prefixthe tool also writes the second source:lessons-docs.source.json(the whole source: the same plugin, connection settings,subfolderand rules as the old one,"identity": "file-id","docs": "read",owns: ["/v2"], and a placeholder for the new folder's ID) andlessons-docs.mappings.json(its rules, everypathunder/v2).--source-idnames it differently. The summary prints the commands that add it.Upload. Create an empty folder in Drive, for example
Lessons-docs. Share it with the server's service account as a reader, as you did the old folder. Then add--upload --to <ID of the new folder>. The tool creates a folder named like--tree(Georgia; change it with--subfolder), then the same folder names below it, so the rules match without changes. Each page becomes a document named like its file (ru,questions) with its pictures inside it, so the new tree needs noimages/folders. Each document is read back and checked again. Uploads run one at a time. When Google answers "too many requests" or a server error, the tool waits and tries again.Rerun to resume. The manifest (
<out>/manifest.json, or--manifest <file>) records each folder and document. A rerun skips the pages that are done. For the others it checks the document an earlier run uploaded instead of uploading it again. To upload a page again, delete its document in Drive and run again. The access token lasts an hour, so a longer run asks for your consent again.Add the second source. Run the two commands the summary printed, with the ID of the new folder:
shfoliwake source add --site my-site --id lessons-docs --owns /v2 --folder <ID of Lessons-docs> \ --subfolder Georgia --identity file-id --key <the old source's key name> --mappings to-docs/lessons-docs.mappings.json foliwake site set --site my-site sources.<index of lessons-docs>.settings.docs readsite showlists the sources in order: the index is the new source's place in that list, counted from 0. The two sources own different paths (/v2and the old source's), so they never claim the same address. The old source is not changed. Do not point the old source at the new folder: a source stays bound to the folder it first synced (SOURCE_BINDING_CHANGED, see Page identity).Sync, preview and check.
foliwake source sync --site my-site --source lessons-docs, then preview. The new pages are at/v2/…in the preview; the old pages are where they were. Compare a few pages of each kind. If the site has a query index for the old paths (query.yaml), add one for the new paths too, with the same columns: the rules give the documents the same fields.Publish when the pages are right. The documents are live at
/v2/…beside the old pages. Switch the app to the prefix; to roll back, switch it back. While both trees are live, edit only one of them (freeze the other), or the two versions drift apart.
The pages of the second source are new pages: new page IDs, and pictures named by the bytes Google keeps, so an app that remembers a learner's progress by a page's content sees new pages once.
Remove the visible IDs of uploaded documents
Documents drive to-docs uploaded before 20 November 2026 show their IDs: {#intro} after slide headings and an ID column in answer rows. foliwake drive strip-ids deletes them: the {#…} after each slide heading, and the ID column of each block form (a form that holds a picture keeps the column, emptied and narrowed: deleting it would make Google re-create the picture). A slide then gets the slug of its heading as its ID (#intro → #kak-ponyat-zhest-regulirovshchika), so a link to its old ID stops working; the run lists every slide ID that changes, old → new, and the ledger keeps the list. An answer whose text or place would not give it its ID (left, straight: IDs the blocks' logic and the learners' progress use) keeps it, typed at the end of its text (Слева {#left}). Nothing else may change: each document is first changed on a copy and compiled with the site's blocks; when its page would differ in anything but those slide IDs (or links to them), nothing is written to it and the run stops. Use the same OAuth client as the upload (drive.file reaches only the documents it created).
Do this only after the server runs an engine that gives slides slugs (21 November 2026); an older one gives such slides h-… IDs.
sh
# one document first, then the whole manifest of the upload; a dry run writes nothing
foliwake drive strip-ids --doc <document ID> --code <site>/build
foliwake drive strip-ids --manifest ./to-docs/manifest.json --code <site>/build
foliwake drive strip-ids --manifest ./to-docs/manifest.json --code <site>/build --apply--folder <ID> takes every document under a Drive folder instead. The dry run applies the very requests --apply sends to a local copy. With --apply they first run on a Drive copy of each document (in a folder "Foliwake strip-ids checks (safe to delete)" in My Drive; the copy is deleted afterwards): Google may apply a request otherwise than the local check assumes, so when the copy's page changes otherwise than expected, the document is not written and the run stops, naming the first line that changed and a diagnostic file beside the ledger (strip-ids-diagnostics/<document ID>-<time>.json: the requests sent, and the element that differs as the copy was before, as Google left it and as the local check expected it; document content only, no credentials). Then each document is changed by one batchUpdate at the revision just read (one an author edited meanwhile is refused and left as it was: run again), then read back and compiled again, and recorded in the ledger (strip-ids.json beside the manifest, or --ledger <file>). A rerun skips the documents the ledger has, so it is safe to resume after an interruption, and it never deletes an {#id} an author types later. Then sync the source, so every page is read again. To undo a document, restore its previous version in Google Docs (File › Version history).
foliwake drive stamp-ids (named ranges instead of visible IDs, 20 November 2026) still works for a document that should keep its old slide IDs invisibly, but it is no longer the way forward: prefer a typed {#id}.
Check one document before a sync
A sync rejects all its new changes when any document has an error (a heading field with two paragraphs, text in an image field). foliwake drive check checks ONE document the way the sync's reader does — the same reader code, the site's blocks from the code folder, then the page pipeline with the Markdown unchanged — and prints every diagnostic as the sync would, code and message. Exit status 1: an error was found, the document would reject the sync. It writes nothing to Drive or the server.
sh
# before an edit: check and keep the document as it is
foliwake drive check --doc <document ID> --code <site>/build --save before.json
# after the edit: check again and see what changed (a unified diff of the lesson's Markdown)
foliwake drive check --doc <document ID> --code <site>/build --diff-against before.json--doc reads the document with your OAuth client, as the other drive commands (drive.file: documents it created, such as those drive to-docs uploaded), after a consent in the browser. --input <file> checks a documents.get JSON you saved another way instead (read with includeTabsContent=true and suggestionsViewMode=PREVIEW_WITHOUT_SUGGESTIONS, as the sync reads it). Each diff hunk is headed by the slide and block it falls in, and names an image by its Docs object ID; the compiled pages are compared too (title, description, fields, body lines) when both versions compile without errors. --json gives all of it as JSON.
"No error found" is not a promise that the sync accepts the document: the check prints what it could not check.
- The source's credentials are not known on this computer, so a credential written in the document is not found.
- Images are not downloaded unless
--images(each gets stand-in bytes);--imagesdownloads them as the sync does (the engine's approved fetch, with the reader's host, type and size checks; only with a document read now: a snapshot keeps no image URL). - Without
--mappings <rules.json> --source-path <folders>/<name>the page gets a stand-in path and no fields from the source's rules, and messages name the document by its title rather than its path in the folder. With them, an ignore rule skips the document, as the sync does. If the source has asubfoldersetting, give it as--subfolder(or keep it in a source object given as--mappings): it is part of the Drive path that messages show and that may be at most 1000 characters. - A document with a name that starts with "." on its path is skipped, as the sync's listing skips it.
- The page is compiled alone: a link to another page is not resolved against the site, and a path another page claims or the source does not own is not found.
Sync, preview and publish
A sync reads the folder into a private snapshot. Nothing changes on the preview or live site until you preview and publish.
- Dashboard: Sources › Update source preview syncs the source and updates its pages in the preview. Review them, then publish from Pages.
- CLI: sync with
foliwake source sync --site my-site --source docs, then preview and publish.foliwake source pending --source docsshows edits in Drive that the last sync does not have yet.
Later syncs are incremental. Foliwake lists the folder, downloads only the files that changed, and keeps the rest. A typical sync after one edit needs one folder listing and one download. foliwake source sync --full reads every file again.
A file that is still being saved. Drive for desktop uploads an edited file in steps. When the downloaded bytes do not match what Drive lists, Foliwake waits a few seconds and tries again. If the file still does not settle, the page keeps its previous version and cannot be published until a later sync reads it. The message says "is still being saved to Google Drive; wait a moment, then update the preview again".
Quotas and limits
| Limit | Value |
|---|---|
| Pages in one sync | 5,000 |
| Size of one Markdown file | 1 MiB |
| Size of one image | 20 MiB |
| Items in one folder | 50,000 |
| Downloads at once | 4 |
| Google API requests in one sync | 50,000 |
| Length of a page's path inside the folder | 1,000 characters |
Google also limits how many API requests a project may make. When Google rate-limits a request, the sync reports SOURCE_RATE_LIMITED; wait and sync again. When the project's daily quota is used up, raise the Queries per day quota of the Google Cloud project, or sync the next day. Incremental syncs keep the number of requests low.
Other ways to sign in
Instead of a service account, the connector can use an OAuth client and a refresh token that a user granted for drive.readonly. Set "auth": "oauth-refresh-token" and name three variables:
json
"credentials": {
"oauthClientId": "MY_SITE_DRIVE_CLIENT_ID",
"oauthClientSecret": "MY_SITE_DRIVE_CLIENT_SECRET",
"oauthRefreshToken": "MY_SITE_DRIVE_REFRESH_TOKEN"
}The folder must then be shared with the user who granted the token. A token with broader access than drive.readonly is refused. Foliwake has no built-in flow to obtain the refresh token.
Troubleshooting
"Drive folder … was not found or is not shared with this source". The folder ID is wrong, or the folder is not shared with the service account. Check folderId and share the folder with the account's e-mail address (Viewer).
"access denied (HTTP 403)". The Drive API is not enabled in the Google Cloud project, or the account has no access to the folder. Enable the Google Drive API (step 1) and check the sharing (step 3).
"Google refused the access token (HTTP 401)" or a refused token request. The key was deleted or the refresh token was revoked. Create a new key and store it again with foliwake credential set (or update the variable on the server and run foliwake docker update).
"the service-account credential is not a Google service-account JSON key". The variable does not hold the whole JSON key. Check that it was copied completely and that the quotes in .env are intact.
"credential variable … is not set". The server has no value of that name. Store it with foliwake credential set (step 4), or add the variable and recreate the server.
The connector is "Disabled by configuration". The server uses its own plugin list file (FOLIWAKE_PLUGINS) that leaves out google-drive-markdown. Add { "shipped": "google-drive-markdown" } to it and recreate the server. The engine's default list turns the connector on.
"the subfolder … does not exist". Check subfolder. Folder names are case-sensitive. If two folders on the way have the same name, the sync stops and asks you to rename one.
"… does not exist in the Drive folder (names are case-sensitive)" for an image. Check the relative path and its upper and lower case. A shortcut to an image is not followed; put the image itself into the folder.
"no valid front-matter id". The source uses identity: front-matter, and the file has no id: line. Add one, or use file-id for a new source.
SOURCE_PATH_UNMAPPED. A Markdown file matches no mapping rule. Add a rule, or an ignore rule for that file.
CONTENT_PATH_DUPLICATE. Two files give the same page path. The message names both files and their IDs.
Two files with the same name in one folder. Drive allows this; Foliwake does not, because the paths would be the same. The sync names each copy's file ID and modification time. Drive for desktop may show the second one as name (1).md. Delete or rename one.
"a Markdown file name contains a credential value". Someone pasted part of the key into a file or a file name. Foliwake refuses such a page. Remove the text, and create a new key, because the old one has been exposed.
