home / docs / sections_fts

Menu

sections_fts: 4

This data as json

rowid title content
4 Linking to static assets Use the static() template function to create cache-busting URLs to static assets from your custom templates. It returns a URL with a ?_hash= parameter based on the file contents and takes the base_url setting into account. When the hash in the URL matches the current file contents, Datasette will serve the static asset with a far-future immutable Cache-Control header. When Datasette is run using --reload , the file contents are hashed every time the template is rendered, so edits to static files will update their URLs without restarting Datasette. Without --reload , the hash is cached for the lifetime of the Datasette process. For Datasette's bundled static assets, pass the path to the asset: <link rel="stylesheet" href="{{ static('app.css') }}"> For plugin static assets, pass the plugin name using plugin= and a path relative to the plugin's static/ directory: <script src="{{ static('plugin.js', plugin='datasette_plugin_name') }}" defer></script> For files served from a directory mounted using --static assets:static-files/ , pass the mount point name using mount= and a path relative to that mounted directory: <link rel="stylesheet" href="{{ static('styles.css', mount='assets') }}"> <script src="{{ static('app.js', mount='assets') }}" defer></script> You can also use urls.path() if you want to link to a mounted file without adding a content hash: <link rel="stylesheet" href="{{ urls.path('/assets/styles.css') }}">
Powered by Datasette · Queries took 5.269ms