Hi All,
I had requirement to add the custom tags under head tag. what is best approach to maintain these in AEM.
As the tags changes for each page. please suggest.
Solved! Go to Solution.
Views
Replies
Total Likes
You can override cq:dialog of your page component and add a new tab.
Refer to the documentation about sling resource merger
Here is a tutorial for customizing page properties
You can override cq:dialog of your page component and add a new tab.
Refer to the documentation about sling resource merger
Here is a tutorial for customizing page properties
Hi @Kummari_DilipKu ,
To manage custom tags under the <head> tag in Adobe Experience Manager (AEM) effectively, especially when the tags can vary for each page, you can use several approaches depending on your specific needs and the flexibility required. Here are some approaches you might consider:
Custom Page Properties: Add a custom field in the page properties where authors can enter the custom tags. This can be achieved by extending the page properties dialog.
Template and Component Inheritance: Ensure that your templates and components can read these properties and render them in the <head> tag.
Context-Aware Configuration: This feature allows for defining configurations at different levels (site, page, etc.) and can be used to manage head tags.
Client Libraries: Use AEM's client library system to inject dynamic head content via JavaScript.
Sling Dynamic Include (SDI): Use SDI to dynamically include content in the head section.
Extend Page Properties Dialog:
<dialog>
...
<items>
<tab>
<items>
<customTags
jcr:primaryType="cq:Widget"
fieldLabel="Custom Head Tags"
name="./customHeadTags"
xtype="textarea"/>
</items>
</tab>
</items>
</dialog>
2. Modify the Page Component HTML:
<head>
...
<meta charset="UTF-8">
<title>${properties.pageTitle}</title>
${properties.customHeadTags @ context='unsafe'}
...
</head>
Fetch Properties Using Sling Models:
@Model(adaptables = Resource.class)
public class CustomHeadTagsModel {
@ValueMapValue
@Default(values = "")
private String customHeadTags;
public String getCustomHeadTags() {
return customHeadTags;
}
}
Include the Model in the HTML:
<head>
...
<meta charset="UTF-8">
<title>${properties.pageTitle}</title>
${customHeadTagsModel.customHeadTags @ context='unsafe'}
...
</head>
By using these approaches, you can effectively manage custom head tags in AEM, providing flexibility for content authors to define tags on a per-page basis.
@Kummari_DilipKu Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies