Markdown Master CMS ships with service worker support out of the box. With a small amount of configuration it becomes a fully installable Progressive Web App (PWA) â installable from the browser address bar, launched in standalone mode, and usable offline.
For the browser to offer an install prompt, all of the following must be true:
localhost during development).
PWA installability is unavailable on plain HTTP.In config.php, enable the service worker:
// Use the bundled service worker.
'serviceWorker' => true,
// Or point to a custom one:
// 'serviceWorker' => '/path/to/my-serviceworker.js',
When enabled, the client registers the worker on page load. The worker caches same-origin assets, serves the active theme's offline page when the network is unavailable, and keeps the site usable once the connection drops.
The server exposes a Web App Manifest at /manifest.json (resolved
{webpath}manifest.json). Each theme ships the <link rel="manifest">
reference in its <head> automatically:
<link rel="manifest" href="{{webpath}}manifest.json">
The manifest values are read from the "pwa" configuration block and can be
set at either level:
themes/<theme>/settings.php. Applies to everyone using
that theme.config.php. Overrides the theme's values and applies to
the whole site.Example config.php:
return [
// ...
'pwa' => [
'name' => 'My Company',
'short_name' => 'MyCo',
'display' => 'standalone', // or: "browser", "minimalUI", "inline"
'theme_color' => '#1e3a5d',
'background_color' => '#ffffff',
],
];
| Field | Description | Default (theme) |
|---|---|---|
name |
Full site name, shown in the install dialog. | Theme default |
short_name |
Short name, shown on the taskbar / app switcher. | Theme default |
display |
How the app launches: standalone (recommended), browser, etc. |
standalone |
theme_color |
Color of the app's status bar / splash. | Theme default |
background_color |
Background behind the app while content loads. | Theme default |
icons |
Auto-generated. Points at the theme's icon set. | â |
Icons are defined by the icons configuration parameter and may point to images within
the theme or application.
For example, if the theme basic-blog ships its settings.php theme config with:
<?php
return [
// ...
'icons' => [
'icons/icon.svg',
'icons/icon-192.png',
'icons/icon-512.png',
'icons/icon-maskable-512.png',
],
];
These 4 icons would be parsed to:
{
"icons": [
{
"src": "/themes/basic-blog/icons/icon.svg",
"type": "image/svg+xml",
"sizes": "any",
"purpose": "any"
},
{
"src": "/themes/basic-blog/icons/icon-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "any"
},
{
"src": "/themes/basic-blog/icons/icon-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "any"
},
{
"src": "/themes/basic-blog/icons/icon-maskable-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
}
]
}
To implement your own brand, add icon images and add an icons block
in your config.php site configuration pointing to the files.
(Keep the maskable icon's content inside the central ~80% circle so it survives the launcher masking).
Icons can be added of varying sizes, with PHP calculating the image size automatically.
The following image sizes are recommended to be used:
| Size | Description | Platform | Rel (where it lives) |
|---|---|---|---|
| 16x16 | Favicon (low res) | All | link @rel=icon |
| 32x32 | Favicon for Chrome, Brave | All | link @rel=icon |
| 48x48 | Favicon for crawlers | All | link @rel=icon |
| 64x64 | Favicon | All | link @rel=icon |
| 120Ã120 | iPhone home screen @2x | iOS | link @rel=apple-touch-icon |
| 128Ã128 | Favicon for Firefox | Windows, Linux | link @rel=icon |
| 180Ã180 | iPhone home screen @3x | iOS | link @rel=apple-touch-icon |
| 192Ã192 | Android home screen / PWA | Android | Manifest |
| 192Ã192 M | PWA maskable | Android | Manifest |
| 256x256 | Windows high-dpi | Windows | link @rel=icon |
| 512Ã512 | Install prompt, splash screen | Android, Linux | Manifest |
| 512Ã512 M | PWA maskable, large | Android | Manifest |
Once configured, the browser shows an install affordance in the address bar (desktop Chrome) or via the share menu (Android). To verify:
Offline behaviour: disconnect from the network and reload. Cached pages are
served; uncached HTML requests fall back to the active theme's offline page
(themes/<theme>/layouts/offline.html).
In client-only mode there is no PHP backend, so /manifest.json is not
generated and the install prompt will not appear. Offline caching of already
fetched assets still works through the service worker, but a full installable
PWA requires the PHP backend.