Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Oct 21, 2025

This pull request makes Site Defaults localizable, allowing fields to differ between sites (eg. Site Name, Google Verification Code).

CleanShot.2025-10-21.at.17.30.05.mp4

A localization will be created for each site. You can optionally configure an "origin" for each localization to inherit its values. Origins can be configured via a modal:

CleanShot 2025-10-22 at 12 48 13

Storage

As part of SEO Pro 7, Site Defaults are being migrated to Statamic's new Addon Settings feature, which gives developers a choice between flat file and database storage for settings.

Localizations are stored as keys in the addon settings data:

# resources/addons/seo-pro.yaml

site_defaults:
  default:
    title: '@seo:title'  
    description: 'This is the description on the English site.'  
    site_name: 'English Site Name'  
    site_name_position: after  
    site_name_separator: '|'  
    canonical_url: '@seo:permalink'  
    robots_indexing: index  
    robots_following: follow  
    og_title: '@seo:title'  
    twitter_title: '@seo:title'  
    twitter_description: '@seo:description'  
    priority: '0.5'  
    change_frequency: monthly
  german:
    site_name: 'German Site Name'
    description: 'This is the description on the German site.'
  french:
    site_name: 'FRENCH'
    # ...
site_defaults_sites:
  default: null
  german: 'default'
  french: 'default'

SEO Pro will migrate your existing site defaults data into this format when you run php please multisite.

Note

While we're using the Addon Settings feature behind the scenes, we're not actually using the publish form it provides. The publish form is custom.

humans.txt

SEO Pro only registers one humans.txt route per domain.

If you have multiple sites on the same domain, SEO Pro will use the defaults for the site on the root of the domain.

PHP API

If you call the SiteDefaults class anywhere in your own code, you will need to update your usage.

The SiteDefaults class has been refactored to allow for localizations. Therefore, you need to get a localization before you can retrieve its values.

- use Statamic\SeoPro\SiteDefaults;
+ use Statamic\SeoPro\SiteDefaults\SiteDefaults;
  
- SiteDefaults::load()->get('foo');
- SiteDefaults::load()->set('foo');
- SiteDefaults::load()->all();
- SiteDefaults::load()->augmented();
  
+ SiteDefaults::in('default')->get('foo');
+ SiteDefaults::in('default')->get('foo');
+ SiteDefaults::in('default')->all();
+ SiteDefaults::in('default')->augmented();

If you listen to the SiteDefaultsSaved event (previously known as SeoProSiteDefaultsSaved), you may need to update your code as the $defaults property is now an instance of LocalizedSiteDefaults.


Closes #289
Related: statamic/cms#12830

The AddonSettingsSaved event will do that for us.
…objects

I wanted them to come from the blueprint instead, but spent too long fighting tests, so I'm gonna keep it the way it was.
@duncanmcclean duncanmcclean marked this pull request as ready for review October 22, 2025 14:05
@duncanmcclean
Copy link
Member Author

duncanmcclean commented Oct 22, 2025

Right now, when you switch localization and edit an inherited field, it won't be saved properly. It's a bug in Core, which I've opened a PR to address: statamic/cms#12830

Gonna merge this into master since the Core PR will be merged before this is released. 🤘

@duncanmcclean duncanmcclean merged commit 0621ff9 into master Oct 22, 2025
29 checks passed
@duncanmcclean duncanmcclean deleted the localizable-site-defaults branch October 22, 2025 14:34
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