Managing CSS and JavaScript in CKAN with Webassets

CKAN bundles theme styles and scripts through Webassets, and CKAN 2.12 replaces debug=true with a dedicated ckan.webassets.debug option. This page explains how to set up, verify and keep those assets from clashing with core and other extensions.

On this page

How CKAN serves theme CSS and JavaScript with Webassets

CKAN uses Webassets to collect, combine and serve the CSS and JavaScript that make up a portal's front end. A portal team needs to manage these assets deliberately once it wants custom styling or scripts, because every stylesheet or script a theme adds loads alongside core pages and other extensions' assets, and a careless change can break a page that has nothing to do with the theme. Theme assets are not dropped into a folder and forgotten. They are declared by an extension, registered with CKAN, and bundled into named groups that templates include by name, so the order, scope and loading of each file is a decision the team owns.

In practice, the team's first task is to inventory what its theme adds: which stylesheets override core Bootstrap rules, which scripts initialize widgets, and which files are needed on every page versus only on dataset or organization pages. Each file is declared in the extension's asset definitions, and the templates reference the bundle rather than the raw file. This keeps the page's <head> and footer predictable and lets CKAN cache and minify the output. Ask the portal's developers which bundles they have defined, and confirm that no template loads a theme file directly, because direct links bypass the bundling and make later upgrades harder to test.

CKAN 2.12 changes how developers switch on unbundled assets during development. The ckan.webassets.debug option now controls this behavior, and the CKAN changelog records that debug=true no longer serves assets individually. Teams that used the old switch in local or staging environments should update their development configuration and test that changes appear as expected before the switch is relied on. Keep ckan.webassets.debug off in production, and confirm the setting in each environment during any upgrade, since a mismatched value can make a working theme look broken in one place and fine in another. The CKAN changelog lists the change alongside the other 2.12 notes.

Which debug setting to use in development and production

On your own machine, you want edited CSS and JavaScript to appear as soon as you save them. In CKAN 2.12, debug = true no longer serves assets individually. Use the ckan.webassets.debug option for that job instead, so your development configuration controls asset output directly. Read the CKAN changelog for the exact wording of this change before you rely on it.

  • Set the dedicated option: add ckan.webassets.debug to your development configuration so unbundled assets are served while you work.
  • Do not depend on Flask debug alone: on 2.12, debug = true by itself does not give you individual asset files, so an asset edit may not show up if only that flag is set.
  • Check older versions separately: if your portal runs CKAN 2.11 or earlier, the previous debug = true behavior applies, so confirm which setting your version reads.
  • Keep the option out of shared files: leave it in your local configuration and do not commit it to the configuration used by other environments.
  • Refresh after each change: do a hard browser refresh after editing assets, since cached files can hide your latest change.

Before you start building, make one small CSS change, confirm it appears in the browser, and check the configuration file you are using.

Asset configuration options and when each fits

This table compares the configuration settings that control how theme CSS and JavaScript are bundled and served in a CKAN portal. Read each row for the situation it suits and its trade-off, then confirm exact key behavior against the CKAN changelog and your own CKAN version before you rely on it.

SettingWhen it fitsTrade-offConfirm before use
ckan.webassets.debug (CKAN 2.12)Local development on CKAN 2.12, when you want unbundled assets for easier debuggingServed assets differ from production bundles, so bugs that appear only in bundled output can be missedCheck the CKAN changelog entry for the option and its default value
debug=true in the development configuration (earlier versions)Development on releases before 2.12, where debug mode served assets individuallyBehavior is not the same as the 2.12 option, so the setting may not produce the same output on 2.12Confirm the behavior for your exact release in the changelog
Production bundling with debug offLive portals, where bundled and minified assets should load for speed and consistent outputChanges need a rebuild or restart to appear, which slows iterationConfirm the asset build step your deployment runs after a theme change
Asset declaration in the extension manifestRegistering your theme's CSS and JavaScript bundles so CKAN includes them in templatesDeclaring too many bundles or large files on every page adds load time for all usersConfirm the bundle names and load order your CKAN version expects
Load order and bundle dependenciesEnsuring your styles override core and other extensions' assets in a predictable orderWrong ordering causes style conflicts that are hard to trace across several extensionsTest with the extensions your portal actually runs, not only your theme

Setting up a theme asset bundle step by step

This sequence takes a theme extension from an empty package to a CSS and JavaScript bundle that loads on a CKAN page, with a check at each stage so problems surface where they start. It gives your team one repeatable path for adding and verifying theme assets without editing core files.

  1. Create the theme extension package

    Start a theme extension as a separate Python package that sits beside your CKAN installation, not inside the core source tree. Your developer registers the plugin in the extension's entry points and adds it to the ckan.plugins setting in your CKAN configuration file, then restarts the web application. Confirm it is done when CKAN starts without errors and the plugin appears in the list of loaded plugins in the logs. If it fails to start, check the package name and entry point spelling first.

  2. Declare the CSS and JavaScript bundles

    Create a Webassets bundle definition in your extension that lists your stylesheet and script files, and register it through the directory structure CKAN expects for assets. Keep the file list short and give each bundle a clear name so templates can refer to it without guessing. Confirm the step by checking that the bundle name is registered and the source files exist at the paths you declared. A missing file or wrong path is the most common reason a bundle will not load later.

  3. Reference the bundles from templates

    Add the bundle names to your theme templates so the page includes them, typically by extending the base template and placing the asset references in the head or the scripts block that the core templates provide. Avoid editing core template files directly. Confirm the reference is in place by reloading a page that uses the template and viewing the rendered page source, where the bundle's link or script tag should appear.

  4. Enable the development setting

    In your development configuration, set ckan.webassets.debug to true so you can see each asset file separately while you work. In CKAN 2.12, debug=true no longer serves assets individually, so this option replaces that older behavior. Restart CKAN and confirm that the page source lists your individual source files rather than one combined file. Leave this setting off in production, where bundling and minification keep pages fast.

  5. Build the bundles for production

    Turn off the debug setting, run the asset build that your CKAN version uses to collect and compile the bundles, and restart the application. The build step produces the combined output that production serves. Confirm it is done when the build finishes without errors and the rendered page references a single bundled file under the static path. If the build reports a missing file, return to the declaration step and correct the path.

  6. Verify the bundle in a browser

    Open a dataset page, the home page and a page from another section in a browser with developer tools open. In the network panel, confirm that the bundle request returns HTTP 200 and the expected file contents, and that your styles or script behavior appear on the page. Check the browser console for errors. Record the bundle filename and the page tested so the same check can be repeated after upgrades or changes to other extensions.

  7. Check for conflicts with other assets

    Load a page that uses another installed extension's styles and scripts, and confirm your rules do not change its layout or behavior. Look for overriding selectors and duplicate script libraries in the page source. Confirm the step by comparing the affected pages before and after your bundle is added. Ask your extension authors or CKAN maintainers to confirm any library version that appears in more than one bundle.

How theme assets move from extension to browser

The path starts in the theme extension, where its asset bundles are declared and handed to Webassets. Core CKAN and other extensions add their own assets to the same pool, which is where filename and ordering collisions can happen. Bundled output reaches the browser through the template layer's script and link tags. With ckan.webassets.debug switched on, Webassets serves individual files instead, so compare the page source and bundle output in each mode before deploying.

Asset path from extension to browser, with the debug switch marked.

Where asset conflicts with core and other extensions come from

Asset conflicts rarely come from one bad file. They come from several places where a theme's CSS and JavaScript meet core CKAN assets, Bootstrap defaults and other extensions. Each card below names one cause, the symptom it produces and the check to run before it reaches production.

Duplicate bundle names

Two extensions that register bundles under the same name can shadow each other, so the page loads one set of files and silently drops the other. The symptom is a feature that works on one portal and breaks on another after an extension is added. Prefer bundle names prefixed with your extension name, and list every registered bundle across the installed extensions before you add a new one.

CKAN changelog

Specificity overrides against Bootstrap

Theme CSS that targets the same selectors as Bootstrap defaults often wins only by chance, and a later core or Bootstrap change can reverse the result. The symptom is spacing, colors or button states that look right in one browser session and wrong after a CKAN patch. Scope your rules under a theme class, avoid !important, and compare rendered pages before and after each core upgrade.

Load order between extensions

When several extensions add CSS or scripts, the order they appear in the page decides which rule or handler runs last. The symptom is intermittent behavior, such as a menu that opens and then closes, that depends on which plugins are listed in ckan.plugins. Record the plugin order in your configuration, test with the full extension set enabled, and avoid depending on the order of unrelated extensions.

JavaScript that assumes a library version

Scripts written against a specific jQuery or Bootstrap API can fail when the bundled version changes during a CKAN minor release. The symptom is a console error and a control that does nothing, often only on pages that use that widget. Check which libraries your code calls, confirm their versions for each CKAN release you support, and test interactive pages after every upgrade.

Template overrides that drop asset includes

A template override that replaces a block can remove the asset include that a parent template loaded, so the feature's CSS or JavaScript disappears without an error. The symptom is a page that renders but lacks styling or behavior on one page type only. Compare your override with the parent template's blocks, keep the asset blocks intact, and check each affected page after changes.

Questions buyers ask about CKAN asset management

How much effort does CKAN theme asset work take, and what drives it?

The effort depends mostly on how much of the portal's look and behavior is custom. A light rebrand that changes colors, fonts and a logo is a small job. A portal with its own layout, custom JavaScript widgets, map or chart components, and several extensions that each ship their own assets takes much more, because every bundle has to be ordered, tested and checked against the others. The main drivers are the number of custom stylesheets and scripts, how many third-party libraries are added, how many extensions touch the same pages, and how many browsers and screen sizes must be supported. Ask any partner for a quote built from a written list of assets, pages and extensions in scope, and separate the one-time build from the recurring cost of retesting after each CKAN upgrade.

Can an internal team manage CKAN assets without a partner?

Yes, if the team has front-end skills and a working knowledge of CKAN's Python plugin system. Bundling assets with Webassets is ordinary Python and template work, and a developer who already maintains a CKAN theme can learn the pattern from the CKAN documentation. The harder part is ongoing discipline: keeping overrides small, checking that a new extension has not loaded a conflicting library, and testing pages after each patch or minor release. Teams without someone who owns that cycle often find the theme drifts from core. Ask whether the staff who will own the assets after launch have been part of the build, not only the people who will hand it over.

What does the work need from our team?

Expect to supply a named technical owner, access to a staging copy of the portal, the brand assets (logos, fonts, color values and any style guide), and a list of the extensions already installed. The team also needs to decide which pages must look different and which must stay as CKAN ships them. Someone must be available to review pages in each browser and device class the portal serves, and to approve changes to shared templates. Ask the partner which of these inputs it expects in writing before work starts, so that delays are not hidden in the schedule.

How do CKAN upgrades affect theme CSS and JavaScript?

Upgrades can change the asset bundles that core and extensions register, so a theme that worked on one minor release may need changes on the next. CKAN patch releases do not break backwards compatibility, while minor releases may include backwards-incompatible changes, according to the CKAN release policy. That makes minor upgrades the point where asset names, template blocks and bundled libraries are most likely to shift. Keep custom assets in a small, named bundle, avoid overriding core stylesheets wholesale, and retest every page type after each upgrade. Check the CKAN changelog for the target release before planning the upgrade window.

How do I stop my assets from conflicting with core and other extensions?

Start by listing every bundle that loads on each page, then give your own styles and scripts narrow selectors and a unique prefix so they do not override core rules by accident. Load your bundle after the core assets it depends on, and avoid shipping a second copy of a library that CKAN or another extension already includes. When two extensions both change the same block, the one loaded last usually wins, so test the combined page rather than each extension alone. Use the browser developer tools to confirm which files load and in what order.

Do I need a partner to build and maintain CKAN theme assets?

Not always. A partner is most useful when the portal needs a custom look across many pages, several extensions must be tested together, or the internal team lacks time to retest after each release. DeployOpen implements, customizes, integrates and supports self-hosted open-source platforms inside the client's own infrastructure, and most engagements are fixed-scope with scope, deliverables and timelines agreed in writing before work starts. Ongoing support and upgrades are available as retainers. Compare any quote against your own staffing plan, and ask what is delivered for the one-time build and what is covered after launch.

How do I check that asset changes work before they reach production?

Test in a staging copy built from the same CKAN version, extensions and configuration as production. Review the key page types (home, dataset, organization, search and user pages), check the browser console for script errors, and confirm the expected files load in the expected order. Repeat the check after every change to a bundle, not only at launch. Development settings can hide problems, so verify the production-style asset output as well as the development view.

What CKAN upgrades change for theme assets

Upgrades are where asset bundles most often break without warning, so the first thing to know is how much each kind of CKAN release can change. CKAN patch releases, such as moving from one 2.11 maintenance release to the next, do not break backwards compatibility and exclude schema changes and new features. Minor releases, such as the move from 2.11 to 2.12, may include backwards-incompatible changes. For a theme that bundles its own CSS and JavaScript through Webassets, a patch upgrade is usually low risk, but a minor upgrade can change the core templates, base stylesheets and script modules your bundles depend on, so the bundle definitions in your theme need checking even when your own code has not changed.

Treat every minor upgrade as a reason to retest the asset pipeline. Check the changelog for each target release before you plan the move, and look specifically for changes to Webassets handling, the ckan.webassets.debug option, and any core bundles your theme extends or overrides. Then confirm that the theme still compiles its bundles, that the expected files load on the pages that matter most, such as the home page, dataset pages and forms, and that no duplicated or missing scripts appear in the rendered HTML. Keep a short record of which assets each page loads before the upgrade so the comparison afterwards is quick.

Also confirm the support window before you choose a target. The CKAN release policy says the tech team supports the latest patch of the current minor version and the previous minor version, and outdated patch releases lose support once a newer patch is out. Ask whether your extensions and any third-party asset libraries you bundle are tested against the release you plan to run. If a minor release lands while your theme is still on an older patch, plan the asset retest as part of the same change window rather than as a follow-up task.

How DeployOpen works on this

DeployOpen plans, builds, documents and supports CKAN theme asset pipelines inside the client's own infrastructure. We start from how your portal's CSS and JavaScript are bundled today, then agree a written scope before any change to the Webassets setup, theme extension or core asset overrides.

How we scope

  • Inventory the theme extension, its asset bundles and every other extension that loads CSS or JavaScript into your portal
  • Confirm the CKAN version in use and whether ckan.webassets.debug is set in development, staging and production
  • Agree in writing which conflicts, bundle changes and browser checks are in scope, since most engagements are fixed-scope

How we build

  • Define bundle ownership so theme assets load in a predictable order alongside core and third-party extension assets
  • Test asset changes in a staging copy of your portal, including debug and production bundling modes
  • Keep overrides small and documented so later CKAN upgrades and extension updates do not break styling

How we hand over

  • Deliver the asset build steps, configuration keys and file layout as written documentation for your team
  • Walk your developers through adding a stylesheet or script and checking that it is bundled and served correctly
  • Record known conflicts with other extensions and the test steps that confirm each one is resolved

How we support

  • Offer ongoing support, upgrade work and continuous testing as a retainer after handover
  • Retest asset bundles when CKAN or an extension you depend on publishes a new release
  • Confirm each upgrade against the CKAN changelog and your own staging environment before production changes

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.