Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

override Context-Aware Configuration (CAConfig) values at the page level

Avatar

Level 2

We are using CAConfig for injecting SEO metadata. It works great at the brand root (/content/brand-x) level. However, we have a requirement where authors should be able to override a few config values like og:title or og:image on a specific page, while still inheriting the rest from the brand-level configuration.

What is the best approach to override only some values at the page level using CAConfig?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @NehaBa4 

You can rely on Page Properties to override SEO values. Check if values from page properties exists then use those otherwise use CA config values.

Arun Patidar

AEM LinksLinkedIn

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @NehaBa4,

To override CAConfig values at the page level while still falling back to parent-level defaults, follow this hybrid approach:

Step 1: Enable CAConfig at Page Level

Ensure your page components or templates allow CAConfig to resolve from the page itself by using:

config = contextAwareConfig.resource().adaptTo(YourSEOConfig.class);

AEM will automatically walk up the content hierarchy (/content/page-x, /content/brand-x, etc.) until it finds a config node.

Step 2: Use Overlaying via /jcr:content/.config

You can override config at the page level by allowing authors to define a hidden configuration node:

/content/brand-x/page-x/jcr:content/.config/com.yourproject.config.SEOConfig

Populate only the properties you want to override - eg. just og:title.

Step 3: Use a Wrapper Sling Model to Merge Configs

Create a wrapper model that merges page-level and brand-level configs:

@Model(adaptables = Resource.class)
public class MergedSEOConfig {

    @Inject @Via("resource")
    @Optional
    private SEOConfig currentPageConfig;

    @Inject
    @Via("resource")
    @DefaultInjectionStrategy(OPTIONAL)
    private ConfigurationBuilder configBuilder;

    public String getOgTitle() {
        if (currentPageConfig != null && StringUtils.isNotBlank(currentPageConfig.ogTitle())) {
            return currentPageConfig.ogTitle();
        }
        return configBuilder.name("com.yourproject.config.SEOConfig").as(SEOConfig.class).ogTitle();
    }

    // Add other fields similarly...
}

Santosh Sai

AEM BlogsLinkedIn


Avatar

Correct answer by
Community Advisor

Hi @NehaBa4 

You can rely on Page Properties to override SEO values. Check if values from page properties exists then use those otherwise use CA config values.

Arun Patidar

AEM LinksLinkedIn

Avatar

Administrator

@NehaBa4 Did you find the suggestions helpful? If you need more information, please let us know. If a response resolved your issue, kindly mark it as correct to help others in the future. Alternatively, if you discovered a solution on your own, we'd appreciate it if you could share it with the community. Thank you.



Kautuk Sahni