Skip to documentation content

Assets and Images

Assets and Images

Register stylesheets and javascript with add_stylesheet and add_javascript, render Image objects with img and image_url, and compile Bootstrap from source.

Register page CSS and javascript with {% add_stylesheet %} and {% add_javascript %}, never with a raw <link> or <script> tag. This is a functional requirement, not a style preference, for two reasons. First, the CMS compiles registered stylesheets (SCSS to CSS) as part of publish and import, so a raw <link> pointed at an uncompiled .scss path will not work. Second, both methods deduplicate: including the same file more than once (for example from several partials on one page) still outputs it only once, where hand-written tags would duplicate it. It's safe to call either method from every partial that needs the asset. The path rules are the same as for an include (Includes).

Images are Image objects, not files, and are rendered with their own methods: see Rendering Images. Styling with Bootstrap Source shows how to compile Bootstrap from SCSS inside the site.