Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to Integrate one script to all pages of metadata

Avatar

Avatar
Ignite 1
Level 1
Mounikasri
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
View profile

Avatar
Ignite 1
Level 1
Mounikasri
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
View profile
Mounikasri
Level 1

18-03-2021

 

There will be one script that we need to add on all the pages in metadata

So can you please help me  where we need to add this script so that it will start loading on all the templates
 
 
 
 
 
Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

372 likes

Total Posts

471 posts

Correct Reply

134 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

372 likes

Total Posts

471 posts

Correct Reply

134 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile
asutosh_jena
Level 10

18-03-2021

Hi @Mounikasri 

If you are trying to include some metadata HTL script across all the pages for any website, please overlay your page template (head.html) file where all the matadata for a page are defined.

Now you can create another HTL file with the required HTL script and include the file in the path at the desired location, preferrably after the metatags.


<meta charset="UTF-8">
<title>${page.title}${page.brandSlug ? ' | ' : ''}${page.brandSlug}</title>
<meta data-sly-test.keywords="${page.keywords}" name="keywords" content="${keywords}"/>
<meta data-sly-test.description="${properties['jcr:description']}" name="description" content="${description}"/>
<meta data-sly-test.templateName="${page.templateName}" name="template" content="${templateName}"/>
<meta name="viewport" content="width=device-width, initial-scale=1">

<-- Your file/custom meta script should go here -->


This will ensure all the pages that are created using this template which uses this page component will have the script loaded.

 

Please refer the core component head.html file below:
https://github.com/adobe/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/...

 

Hope this helps!

Thanks!

Answers (2)

Answers (2)

Avatar

Avatar
Establish
Level 4
Rohit_Utreja
Level 4

Likes

42 likes

Total Posts

44 posts

Correct Reply

15 solutions
Top badges earned
Establish
Give Back 3
Give Back
Boost 5
Boost 3
View profile

Avatar
Establish
Level 4
Rohit_Utreja
Level 4

Likes

42 likes

Total Posts

44 posts

Correct Reply

15 solutions
Top badges earned
Establish
Give Back 3
Give Back
Boost 5
Boost 3
View profile
Rohit_Utreja
Level 4

18-03-2021

@Mounikasri 

 

If you are using a static template, then create a base template. All templates should inherit this base template so this way you will have one location which will be common for all templates.

 

Now, after di=oing above, if you want to add a new script, you can do it in the base template and inheritance will help you to add it on all pages.

Avatar

Avatar
Validate 1
MVP
Nikhil-Kumar
MVP

Likes

240 likes

Total Posts

253 posts

Correct Reply

38 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
MVP
Nikhil-Kumar
MVP

Likes

240 likes

Total Posts

253 posts

Correct Reply

38 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
Nikhil-Kumar
MVP

18-03-2021

@Mounikasri - You can add it in the Base Page template or the template by using which you have created the pages. (In their HTML /JSP files).


Thanks,
Nikhil Kumar