{"id":61778,"date":"2024-06-04T15:13:13","date_gmt":"2024-06-04T09:43:13","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=61778"},"modified":"2024-06-06T17:12:37","modified_gmt":"2024-06-06T11:42:37","slug":"open-graph-tags-in-aem","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/open-graph-tags-in-aem\/","title":{"rendered":"Open Graph Tags in AEM"},"content":{"rendered":"<h2><b>Introduction<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Open Graph tags are defined by the og: meta property and found in the &lt;head&gt; tag. <\/span><span style=\"font-weight: 400;\">In simpler terms, Open Graph tags control how the website\u2019s content appears when shared. <\/span><span style=\"font-weight: 400;\">These tags represent what title, description, and image social media platforms should use when the content is shared.\u00a0<\/span><\/p>\n<h2><b>Why are Open Graph tags important?<\/b><\/h2>\n<p><b>1. Better Appearance <\/b><span style=\"font-weight: 400;\">&#8211;<\/span><span style=\"font-weight: 400;\"> OG Tags convert the page URLs into eye-catching \u201ccards\u201d when shared.<\/span><\/p>\n<p><b>2. Information at a glance-<\/b><span style=\"font-weight: 400;\">They will give a brief idea to the viewers what the content is about.<\/span><\/p>\n<p><b>3. Higher CTRs- <\/b><span style=\"font-weight: 400;\">Enhanced previews significantly increase Click Through Rates. For example, posts with images get more engagement.<\/span><\/p>\n<h2><b>Some Examples of OG Tags<\/b><\/h2>\n<p><b>1. og:title\u00a0 \u2014 <\/b><span style=\"font-weight: 400;\">This tag indicates the title of the page.<\/span><\/p>\n<p><b>2. og:url\u00a0 \u2014<\/b><span style=\"font-weight: 400;\"> Indicates the permanent canonical URL.<\/span><\/p>\n<p><b>3. og:image\u00a0 \u2014 <\/b><span style=\"font-weight: 400;\">The URL of the image linked with the page.<\/span><\/p>\n<h2><b>Code to create the custom og meta tags in AEM:<\/b><b>\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Let me explain the steps. For this, you must have basic knowledge of AEM.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 1. Inside cq:dialog of all the templates used in your project create the fields for Og:title, Og:image and Og:URL as shown below:<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-61779\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Fields-Screenshot.png\" alt=\"\" width=\"941\" height=\"366\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Fields-Screenshot.png 941w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Fields-Screenshot-300x117.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Fields-Screenshot-768x299.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Fields-Screenshot-624x243.png 624w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a02. Inside head.html of page component fetch the value of these fields as shown below:<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-61780\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/HTL-Code-Screenshot.png\" alt=\"\" width=\"977\" height=\"95\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/HTL-Code-Screenshot.png 977w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/HTL-Code-Screenshot-300x29.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/HTL-Code-Screenshot-768x75.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/HTL-Code-Screenshot-624x61.png 624w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a03. The model looks like as shown below:<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-61781\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Sling-Model-Screenshot-First.png\" alt=\"\" width=\"864\" height=\"530\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Sling-Model-Screenshot-First.png 864w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Sling-Model-Screenshot-First-300x184.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Sling-Model-Screenshot-First-768x471.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Sling-Model-Screenshot-First-624x383.png 624w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-61782\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-Code-Screenshot-2.png\" alt=\"\" width=\"854\" height=\"814\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-Code-Screenshot-2.png 789w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-Code-Screenshot-2-300x286.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-Code-Screenshot-2-768x732.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-Code-Screenshot-2-624x595.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-Code-Screenshot-2-24x24.png 24w\" sizes=\"(max-width: 854px) 100vw, 854px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-61787\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Code.png\" alt=\"\" width=\"859\" height=\"342\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Code.png 859w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Code-300x119.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Code-768x306.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Code-624x248.png 624w\" sizes=\"(max-width: 859px) 100vw, 859px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-61784\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-4.png\" alt=\"\" width=\"858\" height=\"218\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-4.png 858w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-4-300x76.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-4-768x195.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Model-4-624x159.png 624w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 4. Code for Constants.java is as below:<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-61785\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Constants-Code.png\" alt=\"\" width=\"865\" height=\"365\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Constants-Code.png 583w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Constants-Code-300x127.png 300w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a05.\u00a0 PathUtils Code is as below:<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-61786\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/PathUtils-Code.png\" alt=\"\" width=\"872\" height=\"601\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/PathUtils-Code.png 863w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/PathUtils-Code-300x207.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/PathUtils-Code-768x530.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/PathUtils-Code-624x430.png 624w\" sizes=\"(max-width: 872px) 100vw, 872px\" \/><\/p>\n<h1>Conclusion<\/h1>\n<p>After completing the steps mentioned above, you can verify by clicking on &#8220;View Page Source.&#8221;<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-62170\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/06\/blog-conclusion.png\" alt=\"conclusion\" width=\"1882\" height=\"150\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/06\/blog-conclusion.png 1882w, \/blog\/wp-ttn-blog\/uploads\/2024\/06\/blog-conclusion-300x24.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/06\/blog-conclusion-1024x82.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/06\/blog-conclusion-768x61.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/06\/blog-conclusion-1536x122.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/06\/blog-conclusion-624x50.png 624w\" sizes=\"(max-width: 1882px) 100vw, 1882px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Open Graph tags are defined by the og: meta property and found in the &lt;head&gt; tag. In simpler terms, Open Graph tags control how the website\u2019s content appears when shared. These tags represent what title, description, and image social media platforms should use when the content is shared.\u00a0 Why are Open Graph tags important? [&hellip;]<\/p>\n","protected":false},"author":1824,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":262},"categories":[5868],"tags":[4847,5924],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/61778"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1824"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=61778"}],"version-history":[{"count":10,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/61778\/revisions"}],"predecessor-version":[{"id":62247,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/61778\/revisions\/62247"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=61778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=61778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=61778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}