Global Repository

To work with the GlobalSet Repository, use the following Facade:

use Statamic\Facades\GlobalSet;


Methods Description
all() Get all GlobalSets
find($id) Get GlobalSets by id
findByHandle($handle) Get GlobalSets by handle
make() Makes a new GlobalSet instance


Globals are a bit unique in that there is a single "container" – the Global Set – which contains common things like its title and handle. The actual variables are stored separately by site (even when not using the multi-site feature).

$set = GlobalSet::findByHandle('theme'); // returns a `GlobalSet`
$variables = $set->in($site); // returns a `Variables`
$variables->get('favicon'); // returns the value

Of course, you can chain this:

Hot Tip!

You must specify your site when working with GlobalSets, even if you only have one. You can use any of these methods:

$set->in('siteHandle'); // A specific site handle from sites.php
$set->inDefaultSite(); // The first site in sites.php
$set->inCurrentSite(); // The site the user is currently visiting.


Start by making a global set instance with the make method. You can pass in the handle.

$globals = GlobalSet::make('settings')->title('Settings');

The variables are stored per-site in a Variables object. You can make one using the makeLocalization method, passing in the site handle. Then attach it to the set.

$variables = $globals->makeLocalization('default');
$variables->data($data); // array of values

Finally, save it.

HR: Section
Learn More!

Learn more about Global Repository in these related docs:

HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →