Knowledge Base/How to model and manage global site settings
How to model and manage global site settings
how-toDeveloperAnalytics
Introduction
When building composable digital experiences, managing site-level settings like cookie policies, Google Tag Manager (GTM) configurations, and other global application settings is a common requirement. These settings need to be easily accessible, maintainable, and performant across your entire application.
This article explores two primary approaches for implementing site-level settings in Uniform, each with distinct advantages depending on your specific use case and architectural requirements.
Solution
Option 1: Component Pattern Approach
Implementation: Use a component pattern that is part of all compositions, such as a global header component, where site settings are modeled as parameters.
Setup Process:
Extend Existing Global Components: If you already have a global header or footer component, add site settings as parameters to this component.
Create Dedicated Settings Component: Alternatively, create a dedicated "Site Settings" component and place it inside a global header slot.
Configure Parameters: Model your settings (GTM ID, cookie policy flags, etc.) as component parameters.
{
"scripts": {
"fetch-settings": "node scripts/fetch-site-settings.js",
"build": "npm run fetch-settings && next build"
}
}
Pros:
Clean Architecture: Dedicated content management for global settings
Enhanced Security: Content Type-level access control and governance
Separation of Concerns: Settings management is isolated from component logic
Cons:
Performance Consideration: Additional fetch operation increases SSR time
Build Dependency: Requires application rebuild for setting changes to take effect
Limited Flexibility: Per-page customization becomes more complex to manage
Recommendation
Choose Option 1 if you:
Already have global components (header/footer) in your architecture
Need frequent setting updates without rebuilds
Require per-page setting customization
Prioritize performance with minimal API calls
Choose Option 2 if you:
Need strong governance and access control over site settings
Have infrequent setting changes
Prefer clean separation between content and configuration
Don't have existing global component patterns
Summary
Both approaches provide viable solutions for managing site-level settings in Uniform. The component pattern approach offers better performance and flexibility for frequent changes, while the content entry approach provides superior governance and architectural clarity. Consider your team's workflow, security requirements, and performance priorities when selecting the most appropriate strategy for your implementation.