Asset Management¶
What are assets?¶
Assets are all the static files needed for Betty to run or generate your site, but that are not source code files. Examples of assets:
imagery
CSS and JavaScript files
(Jinja2) templates
The File System¶
Betty comes with a File System API that layers the assets provided by all the different components.
The order in which files are found:
Project-specific assets found in your project’s assets directory
Assets provided by extensions in the order of their dependency tree
Betty’s built-in assets (
/betty/assetswithin the Betty source code)
This means that extensions can override Betty’s default assets, and your projects can override both extensions’ and Betty’s default assets.
The assets directory¶
For each of Betty’s default assets, extensions’ assets, and your projects’ assets, the assets directory follows the following structure:
./locale/Contains assets for different locales.
./locale/$locale/betty.poWhere
$localeis an IETF BCP 47 language tag,betty.pois the gettext translations file for that locale../public/Contains files that become part of your sites.
./public/localized/Contains files that will be localized when generating your sites.
For sites with a single language, this effectively overrides
./public/static.On multilingual sites, these files end up in a subdirectory based on the locale they are rendered in:
./public/my-page.html.j2will be accessible on your site throughhttps://example.com/en/my-page.htmlfor an English locale, for example.Examples of files that should be put here are any files that contain localizable (translatable) content, which will likely be most, if not all of your HTML pages.
./public/static/Contains static files that become part of your sites.
./public/my-file.txtwill be accessible on your site throughhttps://example.com/my-file.txt.Examples of files that should often be put here are CSS and JavaScript files, images for your site’s look and feel, and metadata files such as
robots.txtandsitemap.xml../templates/Contains (Jinja2) templates.