{"id":60447,"date":"2024-02-28T17:18:25","date_gmt":"2024-02-28T11:48:25","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=60447"},"modified":"2024-06-10T15:33:19","modified_gmt":"2024-06-10T10:03:19","slug":"enabling-headless-for-existing-aem-site","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/enabling-headless-for-existing-aem-site\/","title":{"rendered":"Enabling Headless For Existing AEM Site"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">AEM Headless is a way to expose AEM content, specifically page content in some form like JSON or XML which can be consumed by any application or service.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We have plenty of options available when we think of AEM as headless, and we can suggest these options as per client requirements. Some of them are SPA editors along with sling models popularly known as a hybrid approach, Content fragments with graphQl APIs known as the pure headless approach, etc.\u00a0<\/span><\/p>\n<h2><b>Use Case<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Existing headless AEM approaches work well when content is to be developed fresh. What about the clients who already have tons of content\/pages being developed in a traditional way that uses templates, but they want their existing\/new content to be exposed as content services? We come across such clients frequently, and we guide them with the following approaches:<\/span><\/p>\n<h3><strong>Migrating to AEM as Headless<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\"><strong>1. <\/strong>We create an exhausting list of AEM components specifying what components are using sling models or not. This analysis is important to understand how much cost\/effort is involved. Sling exporters can then be enabled on each component model to expose components in JSON\/XML format.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>2. <\/strong>We can then use the AEM hybrid approach to use SPA editors to create pages.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>3. <\/strong>Content can be freshly created, or some tool can be used to migrate existing content to SPA pages since we have not changed much on component content\/authoring.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>4. <\/strong>This approach requires significant effort as it is mostly equivalent to creating a site from scratch.<\/span><\/p>\n<h3><strong>Using Sling Model Exporters and traditional templates<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\"><strong>1. <\/strong>In this approach, we change nothing on the existing page creation experience; that is, authors can continue working on traditional AEM templates and pages.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>2. <\/strong>Same as in the headless approach, We create an exhausting list of AEM components specifying what components use sling models. This analysis is important to understand how much cost\/effort is involved. Sling exporters can then be enabled on each component model to expose components in JSON\/XML format.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>3. <\/strong>Now, if content needs to be exposed for a page. Any application\/service can make HTTP calls to AEM pages using \u201c.model.json\u201d selector and extension, and the whole page will be exposed as JSON\/XML format in the same way it is exposed in the case of the hybrid approach.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>4. <\/strong>So web pages continue to be served using AEM templates, and other applications\/services can use sling exporters to expose the JSON\/XML content of the page.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>5. <\/strong>This approach also gives us flexibility to decide what should be exposed as JSON or not and what should be used on web pages. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Consider some use cases:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">If the component has a text field the client wants, it is shown differently on the application and web page. We can allow a separate field for this application property on the component dialog, which can be exposed using sling exporters.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">We can eliminate some content\/values to be exported from the Sling exporter&#8217;s JSON\/XML.<\/span><\/li>\n<li><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">We can even allow some extra properties in the dialog that are only meant for application.<\/span><\/span><\/li>\n<\/ul>\n<p>In this blog, we have covered the approaches on how we can enable headless for an existing site. Stay tuned for more upcoming blogs on implementing the same using another approach.<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Introduction AEM Headless is a way to expose AEM content, specifically page content in some form like JSON or XML which can be consumed by any application or service.\u00a0 We have plenty of options available when we think of AEM as headless, and we can suggest these options as per client requirements. Some of them [&hellip;]<\/p>\n","protected":false},"author":994,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":68},"categories":[5868],"tags":[5009,5675],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60447"}],"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\/994"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=60447"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60447\/revisions"}],"predecessor-version":[{"id":60518,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60447\/revisions\/60518"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=60447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=60447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=60447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}