From 0fdbf004843850f200e077a3c87427fe16c18b85 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Thu, 14 Oct 2021 11:39:55 -0700 Subject: [PATCH] Rework the `--static` documentation Rework the `--static` documentation to better differentiate between the filesystem and serving locations. Closes #1457 Co-authored-by: Simon Willison --- docs/custom_templates.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/custom_templates.rst b/docs/custom_templates.rst index efb5b842..3e4eb633 100644 --- a/docs/custom_templates.rst +++ b/docs/custom_templates.rst @@ -173,18 +173,18 @@ Datasette can serve static files for you, using the ``--static`` option. Consider the following directory structure:: metadata.json - static/styles.css - static/app.js + static-files/styles.css + static-files/app.js -You can start Datasette using ``--static static:static/`` to serve those -files from the ``/static/`` mount point:: +You can start Datasette using ``--static assets:static-files/`` to serve those +files from the ``/assets/`` mount point:: - $ datasette -m metadata.json --static static:static/ --memory + $ datasette -m metadata.json --static assets:static-files/ --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 + http://localhost:8001/assets/styles.css + http://localhost:8001/assets/app.js You can reference those files from ``metadata.json`` like so: @@ -192,10 +192,10 @@ You can reference those files from ``metadata.json`` like so: { "extra_css_urls": [ - "/static/styles.css" + "/assets/styles.css" ], "extra_js_urls": [ - "/static/app.js" + "/assets/app.js" ] } @@ -205,10 +205,10 @@ 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/ + $ datasette publish cloudrun mydb.db --static assets:static-files/ -This will upload the contents of the ``static/`` directory as part of the -deployment, and configure Datasette to correctly serve the assets. +This will upload the contents of the ``static-files/`` directory as part of the +deployment, and configure Datasette to correctly serve the assets from ``/assets/``. .. _customization_custom_templates: