Create your first AEM Component
I'd be glad to guide you through creating your first component in Adobe Experience Manager (AEM):
Prerequisites:
- Access to an AEM author instance.
- Basic understanding of AEM's structure and terminology (components, dialogs, templates).
Steps:
-
Project Setup (if applicable):
- If you're working within a project, navigate to the appropriate location under
/apps
in CRXDE Lite (e.g.,/apps/<your-project>
). - If you're not using projects, create a new folder directly under
/apps
(e.g.,/apps/my-components
).
- If you're working within a project, navigate to the appropriate location under
-
Create the Component Node:
- Right-click on the
components
folder (or your project folder) and select "Create" -> "Create Node..." - In the "Name" field, enter your desired component name (e.g.,
myComponent
). - From the "Type" dropdown, select "cq:Component".
- Click "OK" to create the component node.
- Right-click on the
-
Define Component Properties:
- Select the newly created component node.
- In the property editor on the right, set the following properties (these are common, but you might need to adjust them based on your component's functionality):
jcr:title
: A user-friendly title for the component (e.g., "My Simple Component").sling:resourceSuperType
: Set to "cq/Page" to inherit basic page functionalities.componentGroup
: Optionally, specify a group to categorize your component in the authoring UI (e.g., "My Components").
-
Create the HTML Template (Sightly):
- Right-click on the component node and select "Create" -> "File."
- Name the file with a
.html
extension (e.g.,myComponent.html
). - Paste the following basic Sightly template code:
HTML<html> <head> <title>My First AEM Component</title> </head> <body> <h1>Hello from AEM!</h1> </body> </html>
-
Optional: Create a Dialog (for Authoring Properties):
- Right-click on the component node and select "Create" -> "Folder."
- Name the folder
_cq_dialog
. - Inside the
_cq_dialog
folder, create a file namedcontent.xml
. - Define the dialog structure using the Granite UI components syntax (refer to AEM documentation for details). This will allow authors to configure properties of your component in the authoring UI.
-
Save and Deploy (if using a development environment):
- In CRXDE Lite, click the "Save All" button to persist your changes.
- If you're developing in a local AEM instance, deploy your changes to the author instance using your preferred deployment method (e.g., package manager, Git integration).
-
Use Your Component in Pages:
- In the AEM authoring UI, navigate to the page where you want to use your component.
- In Edit mode, drag and drop your component from the "Components" side panel onto the desired location on the page.
- You can then configure any properties exposed through the dialog (if created).
Additional Considerations:
- For more complex components, you might need to create additional folders and files within the component node, such as a
_cq_template
folder for defining the content structure and a_cq_editConfig.xml
file for editing permissions. - Refer to the AEM documentation for in-depth information on component development, dialog configuration, and advanced features.
By following these steps, you'll have created a basic AEM component that can be used on your pages!
Comments
Post a Comment