1) We have in Production an editable template with initial content and now there is a requirement to update a part of this initial content and we want it to reflect on all pages that were first created based on that template.
I know that if I create a new instance of this page, it will have the updated initial content but I want to know whether it is possible or if there are workarounds to have it reflected on the prior created page.
2) If we make a change to the structure of an editable template say delete a component, then, in that case, the deleted component remains in the JCR structure of the pages that were created before. Is there an automated way to clean these orphan components?
1. There's no specific set pattern on how that updated or new content appear along with the existing content (above or below, etc.). 2. A warning is shown on deletion that there would be orphaned nodes on the contents though the page does not show that removed content anymore and deletion of those orphaned nodes might impact large number of contents.
Both the use cases need specific implementation and monitoring of the nodes being updated as it would impact large number of contents. You would have to write that specific logic as per your requirements. You may leverage "Page Structure Conversion Tool" and tweak it as per your needs.
AEM Modernization Tools have a Page Structure Conversion Tool (https://opensource.adobe.com/aem-modernize-tools/pages/plan-operate/usage.html) aimed at converting the page structure from static template to editable template. You can leverage the same UI that it provides (Under Tools > Sites) to find all the pages to be updated under a chosen path and then select as needed to convert. Convert button calls a servlet (com.adobe.aem.modernize.structure.impl.StructureConversionServlet) which reads from the "Page Rewrite Rule" configuration and calls one of the implementation of PageStructureRewriteRule (/src/main/java/com/adobe/aem/modernize/structure/impl/rules) based on service ranking & matches condition and then manipulates/ delete the content as needed. Most of the logic is there though it would not work as is because it's meant for static to editable conversion, you could add a new implementation of PageStructureRewriteRule as needed.