Skip to content

Store section defaults in addon settings #511

Open
ryanmitchell wants to merge 3 commits intostatamic:7.xfrom
ryanmitchell:fix/section-defaults-storage
Open

Store section defaults in addon settings #511
ryanmitchell wants to merge 3 commits intostatamic:7.xfrom
ryanmitchell:fix/section-defaults-storage

Conversation

@ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Mar 4, 2026

Section defaults (the SEO configuration set per-collection or per-taxonomy) were previously stored as inject.seo inside each collection or taxonomy's YAML file. This works fine in a standard Statamic setup, but when using the Eloquent driver in split-config mode — where YAML holds structural config and the database holds content — those files get overwritten on each deployment, wiping any customised section defaults.

This PR moves section defaults storage to addon settings, the same place site defaults already live as of v7. When using the Eloquent driver, addon settings can be stored in the database, so they survive deployments.

What's changed

Storage

Section defaults are now stored under section_defaults in the addon settings file (resources/addons/seo-pro.yaml or equivalent). The format is flat for single-site installs and nested under a sites key for multi-site:

# Single-site
section_defaults:
  collections:
    articles:
      title: '@seo:title'
    pages: false  # disabled

# Multi-site
section_defaults:
  collections:
    articles:
      sites:
        default:
          title: '@seo:title'
        french:
          title: '@seo:title'

Existing inject.seo data
Existing data in collection/taxonomy YAML files is still read as a fallback — nothing breaks on upgrade. The migration happens lazily: the first time you save a section's defaults through the CP, the old inject.seo value is removed from the YAML and the data is written to addon settings instead. If you'd rather migrate everything at once rather than waiting for each section to be touched, you can do so by opening and saving each section in the CP.

Per-site defaults and origin inheritance
Section defaults now support per-site values with origin inheritance, matching how site defaults work. Origins for section defaults are configured independently of site defaults (stored under section_defaults_sites), so you can have different inheritance structures for each.

UI
The section defaults edit page now has a site switcher and a Configure button (in multi-site setups) for setting which site each locale inherits from, consistent with the site defaults UI.

Disabled state
Setting a section to disabled applies globally across all sites, same as before.

@duncanmcclean
Copy link
Member

duncanmcclean commented Mar 9, 2026

Thanks for the pull request! 🙌

This looks good from a quick glance but I'll need to carve out some time to review this probably, so it might be a week or two until I'm able to take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants