diff --git a/datasette/cli.py b/datasette/cli.py
index 67c2fe71..c2c03251 100644
--- a/datasette/cli.py
+++ b/datasette/cli.py
@@ -159,7 +159,7 @@ def plugins(all, plugins_dir):
@click.option(
"--static",
type=StaticMount(),
- help="mountpoint:path-to-directory for serving static files",
+ help="Serve static files from this directory at /MOUNT/...",
multiple=True,
)
@click.option(
@@ -281,7 +281,7 @@ def package(
@click.option(
"--static",
type=StaticMount(),
- help="mountpoint:path-to-directory for serving static files",
+ help="Serve static files from this directory at /MOUNT/...",
multiple=True,
)
@click.option("--memory", is_flag=True, help="Make :memory: database available")
diff --git a/datasette/publish/common.py b/datasette/publish/common.py
index 5bbbf613..ac4e2821 100644
--- a/datasette/publish/common.py
+++ b/datasette/publish/common.py
@@ -33,7 +33,7 @@ def add_common_publish_arguments_and_options(subcommand):
click.option(
"--static",
type=StaticMount(),
- help="mountpoint:path-to-directory for serving static files",
+ help="Serve static files from this directory at /MOUNT/...",
multiple=True,
),
click.option(
diff --git a/datasette/utils/__init__.py b/datasette/utils/__init__.py
index b8df48cf..91ab0d76 100644
--- a/datasette/utils/__init__.py
+++ b/datasette/utils/__init__.py
@@ -730,7 +730,7 @@ def remove_infinites(row):
class StaticMount(click.ParamType):
- name = "static mount"
+ name = "mount:directory"
def convert(self, value, param, ctx):
if ":" not in value:
diff --git a/docs/custom_templates.rst b/docs/custom_templates.rst
index 5cabe152..a939f324 100644
--- a/docs/custom_templates.rst
+++ b/docs/custom_templates.rst
@@ -45,6 +45,9 @@ You can also specify a SRI (subresource integrity hash) for these assets::
Modern browsers will only execute the stylesheet or JavaScript if the SRI hash
matches the content served. You can generate hashes using `www.srihash.org `_
+CSS classes on the
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
Every default template includes CSS classes in the body designed to support
custom styling.
@@ -102,6 +105,48 @@ database column they are representing, for example::
+Serving static files
+~~~~~~~~~~~~~~~~~~~~
+
+Datasette can serve static files for you, using the ``--static`` option.
+Consider the following directory structure::
+
+ metadata.json
+ static/styles.css
+ static/app.js
+
+You can start Datasette using ``--static static:static/`` to serve those
+files from the ``/static/`` mount point::
+
+ $ datasette -m metadata.json --static static:static/ --memory
+
+The following URLs will now serve the content from those CSS and JS files::
+
+ http://localhost:8001/static/styles.css
+ http://localhost:8001/static/app.js
+
+You can reference those files from ``metadata.json`` like so::
+
+ {
+ "extra_css_urls": [
+ "/static/styles.css"
+ ],
+ "extra_js_urls": [
+ "/static/app.js"
+ ]
+ }
+
+Publishing static assets
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+The :ref:`cli_publish` command can be used to publish your static assets,
+using the same syntax as above::
+
+ $ datasette publish cloudrun mydb.db --static static:static/
+
+This will upload the contents of the ``static/`` directory as part of the
+deployment, and configure Datasette to correctly serve the assets.
+
.. _customization_custom_templates:
Custom templates
diff --git a/docs/datasette-package-help.txt b/docs/datasette-package-help.txt
index 39be04e9..92ef09b9 100644
--- a/docs/datasette-package-help.txt
+++ b/docs/datasette-package-help.txt
@@ -12,7 +12,7 @@ Options:
--branch TEXT Install datasette from a GitHub branch e.g. master
--template-dir DIRECTORY Path to directory containing custom templates
--plugins-dir DIRECTORY Path to directory containing custom plugins
- --static STATIC MOUNT mountpoint:path-to-directory for serving static files
+ --static MOUNT:DIRECTORY Serve static files from this directory at /MOUNT/...
--install TEXT Additional packages (e.g. plugins) to install
--spatialite Enable SpatialLite extension
--version-note TEXT Additional note to show on /-/versions
diff --git a/docs/datasette-publish-cloudrun-help.txt b/docs/datasette-publish-cloudrun-help.txt
index 6cdc87eb..d1bc0a9a 100644
--- a/docs/datasette-publish-cloudrun-help.txt
+++ b/docs/datasette-publish-cloudrun-help.txt
@@ -8,7 +8,7 @@ Options:
--branch TEXT Install datasette from a GitHub branch e.g. master
--template-dir DIRECTORY Path to directory containing custom templates
--plugins-dir DIRECTORY Path to directory containing custom plugins
- --static STATIC MOUNT mountpoint:path-to-directory for serving static files
+ --static MOUNT:DIRECTORY Serve static files from this directory at /MOUNT/...
--install TEXT Additional packages (e.g. plugins) to install
--plugin-secret ...
Secrets to pass to plugins, e.g. --plugin-secret
diff --git a/docs/datasette-publish-heroku-help.txt b/docs/datasette-publish-heroku-help.txt
index 88d387a6..96319239 100644
--- a/docs/datasette-publish-heroku-help.txt
+++ b/docs/datasette-publish-heroku-help.txt
@@ -8,7 +8,7 @@ Options:
--branch TEXT Install datasette from a GitHub branch e.g. master
--template-dir DIRECTORY Path to directory containing custom templates
--plugins-dir DIRECTORY Path to directory containing custom plugins
- --static STATIC MOUNT mountpoint:path-to-directory for serving static files
+ --static MOUNT:DIRECTORY Serve static files from this directory at /MOUNT/...
--install TEXT Additional packages (e.g. plugins) to install
--plugin-secret ...
Secrets to pass to plugins, e.g. --plugin-secret
diff --git a/docs/datasette-publish-nowv1-help.txt b/docs/datasette-publish-nowv1-help.txt
index c2bf23f1..1d23fe3f 100644
--- a/docs/datasette-publish-nowv1-help.txt
+++ b/docs/datasette-publish-nowv1-help.txt
@@ -8,7 +8,7 @@ Options:
--branch TEXT Install datasette from a GitHub branch e.g. master
--template-dir DIRECTORY Path to directory containing custom templates
--plugins-dir DIRECTORY Path to directory containing custom plugins
- --static STATIC MOUNT mountpoint:path-to-directory for serving static files
+ --static MOUNT:DIRECTORY Serve static files from this directory at /MOUNT/...
--install TEXT Additional packages (e.g. plugins) to install
--plugin-secret ...
Secrets to pass to plugins, e.g. --plugin-secret
diff --git a/docs/datasette-serve-help.txt b/docs/datasette-serve-help.txt
index 1447e84d..e71e177d 100644
--- a/docs/datasette-serve-help.txt
+++ b/docs/datasette-serve-help.txt
@@ -20,7 +20,7 @@ Options:
-m, --metadata FILENAME Path to JSON file containing license/source metadata
--template-dir DIRECTORY Path to directory containing custom templates
--plugins-dir DIRECTORY Path to directory containing custom plugins
- --static STATIC MOUNT mountpoint:path-to-directory for serving static files
+ --static MOUNT:DIRECTORY Serve static files from this directory at /MOUNT/...
--memory Make :memory: database available
--config CONFIG Set config option using configname:value
datasette.readthedocs.io/en/latest/config.html