The admin UI
The browser admin that motabhai serve provides: a dashboard, a page tree, forms, a document-like editor that shows Markdown formatted as you type with a slash menu, drafts, a live preview, a media library, databags, search, shortcuts and deploying.
motabhai serve also serves an admin UI at /admin/,
http://127.0.0.1:5000/admin/ by default. It is part of the binary, has
no accounts, and is meant for one person editing their own site on their
own machine. A build does not include it. It needs JavaScript, which
every browser has on by default.

Getting around
- The shell. Every admin page has a sidebar and a top bar. The sidebar holds the site's name, the navigation (Dashboard, Pages, New, Themes, Media, Databags) and the page tree. The top bar shows where you are, the build status, the actions of the page you are on, View site, and the theme toggle.
- The build status in the top bar says whether the dev server is building, has built, or failed to build, and changes as builds happen, without reloading the page. It leads to the dashboard, which shows the error report of a failed build: the same report the terminal prints.
- The page tree in the sidebar shows the top-level pages and the branches leading to the page you are editing, which is highlighted. The arrow beside a page opens or closes the pages under it; they are fetched as the branch opens, a hundred at a time with a "Show more" button after them, so a large blog does not slow every page down. The admin remembers which branches you opened or closed, per site, in your browser. Hidden pages are marked, a site with translations has a link per language on each row (struck through where the page is not translated yet), and the "+" on a row adds a page under it.
- Filter pages, above the tree, narrows it as you type to the pages whose title (in any language), ID or path contains what you typed, shown inside their parents. Enter opens the first match and Escape clears the filter.
- Search and the command palette. Ctrl+K (Cmd+K on a Mac), or the
Search button in the top bar, opens a box that finds pages and
actions as you type. Pages are found by title (in any language, a
translation opening in its language), ID or path, with exact matches
first and hidden pages marked; actions are the screens, New page,
a New
for each page whose model names its children's model, Deploy, View site, Switch theme and Keyboard shortcuts. The arrows move, Enter goes and Escape closes. With nothing typed it lists the pages you edited last, kept in your browser, and on an edit page the page's own actions: View page, Add child, Move or rename and Delete. - Keyboard shortcuts, when you are not typing in a field or the code
editor:
/moves to the sidebar's filter,gthendgoes to the dashboard,gthenpto Pages,nto New and?lists them all. - Pages at
/admin/pagesis a table of every page with its path, model, the day it was created, whether it is hidden and its languages, as on the quickstart page. The day is the page's_created: the admin writes today's date into every page it creates. A page made by hand, or before motabhai did this, records no day; for it the column shows, in italics, the day its file was made on your machine, which after a fresh clone is the day of the clone. Add the_createdline yourself to fix its day. The table, and the page tree in the sidebar, list each page's children by that day, newest first, and by name within a day. That is the admin's order only: the order of a list on the site is the model'sorder_by, where["-_created"]gives the same for pages that record their day. - The theme toggle in the top bar shows the admin light, dark, or following your system. The choice is kept in your browser.
- On a narrow screen, below about 900 pixels, the sidebar hides behind the menu button at the top left. Escape, or a tap beside it, closes it.
The dashboard and deploying
- The dashboard at
/admin/is the first screen. It shows how the last build went (when, how long, how many files were rebuilt, unchanged or removed, or the error), how many pages the site has and how many are hidden, and for a site with translations how many pages each language is missing. It lists the pages changed most recently (by the time of their file) and the hidden pages, and the Changes and Deploy panels below. - Changes appears when the site is in a git repository and git is
installed. It shows the branch, the last commit, and the files of
content/,models/,templates/,databags/andmotabhai.tomlwith uncommitted changes, each linked to the form that edits it where there is one. The admin only reads: it runs no git command that writes, not even one that refreshes the index. Commit with git as usual. Without git, or outside a repository, the panel is simply not there. - Deploy lists the site's deploy targets with their type
and destination. Deploy asks first, naming the target and where it
goes, then runs
motabhai deploy <name>in the project, exactly as on the command line: the hooks, a full build into the directory the dev server serves, and the upload. Its output appears as it is printed on/admin/deploy, until it ends with success or the error. One deploy runs at a time; the dev server's rebuilds, and page requests waiting for them, wait until it ends, and the site is rebuilt after it. The page shows a destination but never a credential: a password or token written into a URL is left out, and environment variables such asAWS_SECRET_ACCESS_KEYare only seen by the deploy itself, which reports a missing one in its error. A site without targets says how to add one.
Editing pages
- Edit forms come from the page's model, with one input per field
type: text inputs, text areas, number inputs, checkboxes, date inputs,
select boxes and checkbox groups.
stringsfields take one item per line. Each field'sdescriptionis shown as help text, and placeholders show the default value. "Page settings" holds the system fields_slug,_template,_hidden,_discoverableand_redirect_from._hiddenand_discoverableare Yes, No or Inherit, and_redirect_fromtakes one URL per line. The root page has no_slugor_redirect_from. - The flow block editor adds, removes and reorders the blocks of a
flowfield. Its buttons change the form; nothing is written until you save. - A live preview of the page can sit beside the form and follows what you type: a moment after you pause, it shows the page as it would be if you saved now, with the site's own styles, without writing anything. It keeps its scroll position. While the form holds something a save would refuse, such as an emptied required field, the last good preview stays and a small badge over it names the problem. In the Editor view the preview is hidden, so the badge is not seen: the problem shows at the field when you save. After a save the preview is the built page again. Split, Editor and Preview above the form choose both sides, the form alone or the preview alone, and the choice is remembered. A form opens in Split and a writing layout page in Editor, until you choose. Screens narrower than 1200 pixels show one or the other. View opens the built page in a new tab. A hidden page is not built, so it has neither.
- Save with the button at the bottom of the form, which stays in view as you scroll, or with Ctrl+S (Cmd+S on a Mac). "Saved." appears in a corner for a few seconds. Invalid input is shown again with each problem and its error code, and nothing is written. When something the page does in the background is refused, such as adding a flow block to a page whose file has gone, the reason appears in the same corner.
- The code editor.
markdownandhtmlfields are edited in a code editor with soft wrap, undo, find and replace (Ctrl/Cmd+F) and a line and word count.htmlfields show highlighted source.markdownfields show their text formatted as you type, with a slash menu and a Source button for the raw text. Enter continues a list or quote, and Tab indents; press Escape, then Tab, to move on to the next field instead. Markdown fields have a toolbar and shortcuts: bold (Ctrl/Cmd+B), italic (Ctrl/Cmd+I), link (Ctrl/Cmd+Shift+K), heading, quote, inline code, code block, bulleted and numbered lists and a horizontal rule; each wraps the selection or toggles the line's prefix. Ctrl/Cmd+S saves from inside it. The file keeps exactly the text typed.textandstringsfields are plain textareas that grow as you type. - Pages can be moved, renamed and deleted, from the actions in the top bar. Moving a page moves its directory, with its children, translations and attachments. Deleting asks first, and removes the page's directory with the pages and attachments in it. The root page can be neither moved nor deleted.
- Page settings and Attachments are panels under the fields that open and close. Attachments is open when the page has any.
- New in the sidebar creates a page. It has a shortcut for each page
whose model sets
[children] model, such as "New Blog post" for a blog, and a choice of parent for a page anywhere else. The "+" on a row of the tree and "Add child" on a form add a page under that one. Where the parent allows several models, the form has a choice of model. The ID is suggested from the title, and made from it if left empty. - Reorganising from the tree. Drag a page onto another, in the sidebar or on the Pages screen, to move it under that page (children have no manual order, so dragging never reorders). A dialog first shows the old and the new URL, because a move changes URLs; the server still decides, and a refused move shows its reason and moves nothing. Pages whose model takes no children are not drop targets. On the Pages screen, the rename button or F2 turns a title into an input for the page's ID (its directory and the end of its URL), with the same URL check; titles are changed in the form. "Move or rename" remains for the keyboard.
- Bulk actions. Tick pages on the Pages screen (or "Select all", or
"Select branch" for everything under the ticked pages), then Hide,
Unhide or Delete. Hide and Unhide change only
_hidden. Delete asks first, counting the pages and attachments that go; a page whose parent is deleted too is skipped, as it goes with it. Each page succeeds or fails on its own, and the toasts after the reload list what was done and each refusal. The home page is always refused. - Translations are edited in their own form, which shows the primary
language's values as placeholders, and saved to
index.<code>.md. Deleting a translation removes only that file. - The Edit button. Every page the dev server serves has an Edit button in the corner that opens that page's form. On tag pages and further pages of a list, it opens the page they belong to. The preview inside the admin does not show it.
Writing a page
- The writing layout. A page whose model has a
titlefield of typestringand amarkdownfield withbody = trueis edited as a document, not as a form. From the top: the title in large type, a Properties panel, the body, then any flow fields, Page settings and the Save button, then Attachments. The title has no card or label. Its placeholder is "Untitled" unless the model sets one. Enter in the title moves to the body and does not save. - Properties holds every other field of the model, with their count in its heading. It is closed when the page opens, and open when a field in it has a problem after a refused save. Fields in a closed panel are still saved. A model with only a title and a body has no Properties panel.
- The body has no card or label, and grows with its text, so the page scrolls and not the editor. Its toolbar stays in view as you scroll.
- The default view on this layout is Editor, the writing alone. Split and Preview are still above the page. Whatever you choose is remembered in this browser, and applies to every page.
- Other models keep the form. So does the New page form, which
is the same for every model. A model whose
titleis not astring, or that has no Markdown body, is edited as a form.
Formatting as you type
Markdown fields show their text formatted as you type, in place. This is the default. The text is still Markdown: the file holds exactly the characters typed, and nothing is rewritten when the page is shown or saved.
- Inline. Bold, italic, strikethrough and inline code are shown styled. A link shows its text, styled as a link, without the address.
- Blocks. Headings are shown at a size for their level. Lists have bullets or numbers, quotes have a bar, a horizontal rule is a line, and a fenced code block is a monospace block.
- The marks show where the cursor is. The
**around a word show while the cursor is in the word, the##before a heading while the cursor is on its line, and the fences of a code block while the cursor is anywhere in it. They hide again when the cursor leaves. The arrow keys move through hidden marks as through any text, and End goes to the end of the line, after any hidden marks. Hidden marks are hidden from assistive technology as well as from sight, so a screen reader reads the formatted text. Source shows the document's full structure as text. - To-do items.
- [ ]and- [x]are shown as checkboxes. Click one to tick or untick the item, or press Ctrl+Enter (Cmd+Enter on a Mac) with the cursor on the item's line. Only the[ ]or[x]changes. - Source. The Source button on the toolbar shows the raw Markdown
instead, with syntax colours and nothing rendered. It applies to every
Markdown field on the page. Press it again to go back. Your text and
cursor stay where they were, and the choice is remembered in this
browser.
htmlfields have no Source button: they always show source. - The toolbar, its shortcuts, list continuation on Enter, Tab, find and replace (Ctrl+F, or Cmd+F on a Mac), undo, the line and word count and Ctrl/Cmd+S work the same in both modes. The count is of the Markdown as typed. Colours follow the light or dark theme.
Code blocks
A fenced code block gets syntax colours when the line that opens it names one of these languages. Colours show in both modes.
| Language | Names |
|---|---|
| JavaScript | javascript, js, jsx, mjs, cjs, node |
| TypeScript | typescript, ts, tsx |
| JSON | json, jsonc |
| HTML | html, htm |
| CSS | css |
| Python | python, py |
| Rust | rust, rs |
| Shell | shell, sh, bash, zsh |
| TOML | toml |
| YAML | yaml, yml |
| SQL | sql |
A block with no language, or any other, is shown in one colour. That is not an error.
Images and tables
- Images. A Markdown image whose address is on this site, relative to
the page or starting with
/, is shown under its line, scaled to fit. An image that does not load is shown as a placeholder with its description and address. So is an image from another site: the editor never asks another site for anything. A hidden page is not built, so its images are always placeholders. - Tables. A pipe table is shown as a grid with a header row, the formatting inside its cells and the column alignment. A table wider than the editor scrolls sideways by itself. Click a cell to see the table's Markdown with the cursor in that cell. Move the cursor out and the grid returns.
Inserting blocks
Type / on an empty line to open the slash menu. Indentation, a list mark
or a quote mark before the / is fine. Text after the / narrows the
list by name or alias. The arrow keys move, Enter or Tab inserts, a click
inserts, and Escape closes the menu and keeps what you typed. If nothing
matches, the menu closes. A / inside a sentence or inside code opens
nothing.
| Item | Alias | Inserts |
|---|---|---|
| Text | an empty line | |
| Heading 1 | h1 | # |
| Heading 2 | h2 | ## |
| Heading 3 | h3 | ### |
| Bulleted list | ul | - |
| Numbered list | ol | 1. |
| To-do list | todo | - [ ] |
| Quote | > | |
| Code block | code | a pair of fences, with the cursor between them |
| Divider | hr | --- and a line break, with the cursor on the next line |
| Table | a table of two columns, with "Column 1" selected | |
| Image | img | , with "address" selected |
The menu works in both modes. An empty Markdown field shows the hint "Type '/' for commands", or the model's own placeholder when it has one. The hint is not part of the text.
Two typing shortcuts:
[]at the start of a line becomes- [ ], a to-do item.- Enter at the end of a line that opens a code fence, such as three
backticks and
rust, adds the closing fence on the line below and puts the cursor between them. This only happens when the fence has no closing one yet.
Ctrl+Z (Cmd+Z on a Mac) undoes either in one step and gives back what you typed. On a Mac, Ctrl+Z works in the editor too.
Unsaved changes and drafts
Saving is always your choice. Nothing is saved on its own.
- Unsaved changes appears beside Save when the form differs from the page as it was loaded, and goes away when you change it back. It also shows after a refused save.
- A draft of the whole form (fields, page settings and flow blocks) is kept in this browser a moment after you stop typing. It is kept separately for each page and each language. It is never sent anywhere except back to this site when you restore it. When the form is back to how the page was loaded, the draft is removed.
- Coming back. If you leave without saving and open the page again, a banner above the form reads "Unsaved changes from" and the date and time, with Restore and Discard. The form still shows the page as it is on disk. Nothing is put back until you click Restore.
- Restore fills the form with the draft, including added, removed and moved flow blocks. It does not save and does not reload the page. The page shows "Unsaved changes", and Save writes the restored values. Fields the model no longer has are ignored.
- Discard removes the draft and leaves the form as loaded.
- Changed on disk. If the page's file changed since the draft was made, for example you edited it in another editor, the banner adds "This page has changed on disk since." Restoring then replaces those newer values with the draft's, so look before you save. Restore and Discard work as before.
- Typing past the banner replaces the old draft with the new edits and removes the banner.
- When drafts go. A successful save removes the page's draft for that language. A refused save keeps it. Drafts older than 30 days are removed when any edit page is opened. Drafts are for the edit form only, not for New page or databags.
- Leaving a page with unsaved changes gives no warning, because the draft makes leaving safe. A browser that does not allow storage works as before, without drafts and without an error.
- This browser only. Drafts do not follow you to another browser or another machine, and clearing the browser's site data removes them.
Notebook posts
A page of a model that allows "notebook" in its formats can be a Jupyter
notebook. The Pages table, the page tree and search results mark such a
page with a Notebook tag, and its edit page shows the notebook's cells in
place of the body: Markdown cells in the editor above (as plain source,
each with a Preview button), code cells in a code
editor with their stored outputs under them, read-only. Cells can be added,
moved, deleted and switched between code and Markdown, and nothing is
written until you save. See Notebook posts for creating
one and for what saving keeps.
With [notebook] execute = true on a local dev server, each code cell has a
Run button, with Run all, Interrupt and Restart, and the outputs appear under
the cell; see Running cells in the admin for what that
needs and starts.
Themes
- Themes in the sidebar lists the installed themes, marks
the one in use, and changes the one the site uses, by rewriting
themeinmotabhai.toml. It also lists the site's own templates and assets, which replace the theme's.
Media
- Attachments can be uploaded, several at a time, and deleted after
a confirmation.
Uploading a file with the name of an existing attachment replaces it. An
upload can be up to 256 MB. Only the file's own name is used, and a name
that would make it a content file, such as
index.md, or that starts with a dot is refused (motabhai::admin::invalid_attachment). A page whose model turns attachments off takes none. - The media library at
/admin/medialists every attachment of the site as a grid or a list: a thumbnail (an icon for files that are not images), the file's name, its page, type, size and, for images, its dimensions. Filter by name or by kind (images, documents, other) and sort by name, size or page. "Used by" names the pages that read the file when they were last built, and says "Not referenced by any built page" rather than "unused", because a page can link to a file in ways the build does not see; before the first build it says "Not built yet". Copy link puts(an image) or[name](name)on the clipboard, to paste into the page that owns the file. Upload to any page whose model takes attachments, and delete after a confirmation that names the pages using the file. The attachments panel of a page's form shows the same thumbnails, sizes and copy button. Thumbnails are made on demand (240 pixels at most) and kept in.motabhai/previews/; an SVG is shown as it is.
Databags
- Databags at
/admin/databagslists the files ofdatabags/with the top-level keys of each. A databag opens in a code editor with TOML highlighting. Save writes exactly what was typed, with line endings made\nand a final newline, so comments and order stay as they were, and the pages that callbag()rebuild. Text that is not valid TOML is refused (motabhai::admin::invalid_databag): nothing is written, the text comes back in the editor, and the error's line, column and message are shown with the line marked. New databag takes a name of letters, digits,-and_(a.is out becausebag("a.b")reads the keybofa). Delete asks first and names the templates oftemplates/and of the theme in use that callbag("name"), found by a text search.
How it writes files
Saving rewrites only what changed. A value you did not touch is left exactly as written, comments and formatting in the front matter survive, and the body is kept byte for byte unless you changed it. Fields you empty are removed from the file, so the default applies again. The admin reads the files afresh on every request, so edits made in your editor show up at once, and the reverse.
There is no undo of a save, and two tabs saving the same page overwrite each other. Keep the site in version control. There is no autosave: the file changes only when you save, and drafts only protect what you have not saved yet.
Safety rules
The admin can write to your files, so it only answers this machine:
- It is only served on a loopback address. With the default
--host 127.0.0.1it is on. With any other address, such as--host 0.0.0.0to try the site from a phone, the server says the admin is off, and/admin/is the site's 404. - It answers only requests whose
Hostislocalhostor a loopback IP, which defeats DNS rebinding. - It refuses writes that a browser marks as coming from another site
(through
Sec-Fetch-SiteorOrigin), so a web page you visit cannot post to it, or start a deploy.
Limits
- The admin needs a site that loads. If a content or model file is broken, every admin page shows the error report instead, and the file has to be fixed in an editor. Databags can still be edited, and the deploy page still shows the last deploy.
- A deploy started from the admin lasts as long as the server: stopping
motabhai servestops following it, and the admin keeps only the last deploy's output. /admin/shadows a page at/admin/when the base path is/.- Moving a page does not update links to its old URL or add a
_redirect_from. - The live preview draws one page: the page of the record being edited, as its first page if it is paginated. A thumbnail the draft asks for that no build has made yet is a broken image until you save, and other pages that show the record (a list, a tag page) change only when you do.
_modelcannot be changed in the admin, and date-times are plain text inputs.- The editor's formatting is an aid, and can differ from the built site at the edges. The Split or Preview view shows the real page.
- The editor loads images only from this site. Images from other sites, and all images of a hidden page, are shown as placeholders.
- A table inside a quote or inside an indented list item stays as Markdown. So do reference-style links and autolinks, which are not shown as links. An image inside a table cell is shown as its Markdown in the grid, not as a picture.
- To-do checkboxes are always drawn as checkboxes in the formatted view.
To edit the raw
[ ], use Source. - The New page form does not have the writing layout.