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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Add data-nosnippet html attribute to a DIV contains text

Avatar

Level 1

Dear community members,

My AEM site has a content section that is wrapped within a master Div class. To tell Google not to use textual parts of an HTML page as a snippet showing on SERP. The site's textual parts are wrapped within a master div class (<div class="content box section">)

Google Documentation: https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag#data-nosnippet-attr


It would be a great help if, anyone here guide me on how it is possible to add HTML attributes within a DIV class.

Happy New Year in advance.
Thanks,
Saday Kumar

3 Replies

Avatar

Level 5

Hello @Sadaykumar 

 

I hope you have also explored "Robots" property available in Page properties. It has following options OOTB

aanchalsikka_0-1672047519734.png

 

Avatar

Level 1

Thank you @aanchal-sikka for your reply.. 

I belive, this will add nosnippet tag for all the content present on the page. Kindly let me know will this tag help to add data-nosnippet to a piece of content section? 

 

Example

 

Lorem ipsum dolor sit amet. Eos dolore expedita ut dolores beatae ab voluptas nisi. In debitis voluptatem in aspernatur rerum sed nostrum rerum. - Fine to appear on SERP

 

Qui error dolore quo ratione dolores ut nihil mollitia vel culpa sint a cupiditate maxime sit enim tempora non voluptatibus aliquid. Ea repudiandae vero eos consequatur dolorem ab voluptas magnam et quia voluptatum! Est odio omnis hic nisi nobis eum dolor assumenda. - I dont want this content piece appear on SERP and need to add data-nosnippet within this content div. 

 

Ad eaque accusantium et voluptas suscipit eos voluptatem voluptatem et beatae praesentium **bleep** tenetur explicabo. Sit nostrum magni **bleep** dolor atque sit libero consequuntur aut corporis sunt in rerum illum. - Fine to appear on SERP

 

Hope I am able to elaborate the situation and its making sense. It would be great if you help me in this context.

 

Thanks

Saday

Avatar

Community Advisor

I would assume your AEM web page is made up of several component's, and your content author's would like granular control, on which component blocks should have the data-nosnippet or not.

How I am going to do this is by adding the data-nosnippet feature to my components. I would target the affected component's and then add a new section in the touch ui called "SEO",. Within the "SEO" section, include a checkbox for data-nosnippet. When this checkbox is enabled, the data-nosnippet will appear, and if not (default setting), the HTML element will never exist.