Reusing content across sites with AEM authoring as your content source

By default, AEM is tightly bound to your code repository, which meets the majority of use cases. However you may have multiple sites that differ mostly in their content, but could leverage the same code base.

Rather than creating multiple GitHub repositories and running each site off a dedicated GitHub repository while keeping them in sync, AEM supports running multiple sites from the same codebase.

This simplified setup, which eliminates the need for code replication is also known as “repoless”, because all but your first site don’t need a GitHub repository of their own.

If your project requires the repoless flexibility of code reuse across sites, you can activate the feature.

Regardless of how many sites you want to ultimately create in a repoless fashion, you must create your first site, which serves as your base site. This document explains how to create your first site for repoless use.

Prerequisites

To take advantage of this feature, make sure you have done the following.

You will also need to ask Adobe to configure the following items for you. Reach out via your Slack channel or raise a support issue to request Adobe to make these changes:

Activate repoless feature

There are several steps to activate repoless functionality for your project. Please substitute your own site and GitHub org information appropriately.

  1. Retrieve access token
  2. Set up configuration service
  3. Add site configuration and technical account
  4. Update AEM configuration
  5. Authenticate site

This document details each of these steps.

Retrieve access token

You will first need an access token to use the configuration service and configure it for the repoless use case.

  1. Go to https://admin.hlx.page/login and use the login_adobe address to login with the Adobe identity provider.
  2. You will be forwarded to https://admin.hlx.page/profile.
  3. By using your browser’s developer tools, copy the value of the x-auth-token either from the JSON web token cookie that the admin.hlx.page page sets.

Once you have your access token, it can be passed in the header of cURL requests in the following format.

--header 'x-auth-token: <your-token>'

Add path mapping for site configuration and set technical account

You need to create a site configuration and add it to your path mapping.

  1. Create a new page at the root of your site and choose the Configuration template.
    • You can leave the configuration empty with only the predefined key and value columns. You only need to create it.
  2. Create a mapping in the public configuration to the site configuration using a cURL command similar to the following.
curl --request POST \
  --url https://admin.hlx.page/config/<your-github-org>/sites/<your-aem-project>/public.json \
  --header 'x-auth-token: <your-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "paths": {
        "mappings": [
            "/content/<your-site-content>/:/",
            "/content/<your-site-content>/configuration:/.helix/config.json"
   ],
        "includes": [
            "/content/<your-site-content>/"
        ]
    }
}'
  1. Validate that the public configuration has been set and is available with a cURL command similar to the following.
    curl 'https://main--<your-aem-project>--<your-github-org>.aem.live/config.json'

Once the site configuration is mapped, you can configure access control by defining your technical account so it has privileges to publish.

  1. Sign into the AEM author instance and go to ToolsCloud ServicesEdge Delivery Services Configuration and select the configuration that was automatically created for your site and tap or click Properties in the tool bar.
  2. In the Edge Delivery Services Configuration window, select the Authentication tab and copy the value for the technical account ID.
    • It will look similar to <tech-account-id>@techacct.adobe.com
    • The technical account is the same for all sites on a single AEM author environment.
  3. Set the technical account for your repoless configuration with a cURL command similar to the following, using the technical account ID that you copied.
    • Adapt the admin block to define the users who should have full administrative access to the site.
      1. It is an array of email addresses.
      2. The wildcard * can be used.
      3. See the document Configuring Authentication for Authors for more information.
curl --request POST \
  --url https://admin.hlx.page/config/<your-github-org>/sites/<your-aem-project>/access.json \
  --header 'Content-Type: application/json' \
  --header 'x-auth-token: <your-token>' \
  --data '{
    "admin": {
        "role": {
            "admin": [
                "<email>@<domain>.<tld>"
            ],
            "config_admin": [
                "<tech-account-id>@techacct.adobe.com"
            ]
        },
        "requireAuth": "auto"
    }
}'

Since you now use the configuration service, you can remove fstab.yaml and paths.json from your Git repository.

NOTE: By using the configuration service and exposing the path mapping via config.json, the path.json file is ignored.

Once AEM is configured for repoless use, you must use the configuration service and provide a valid config.json with the paths mapping.

Update AEM configuration

Now you are ready to make the necessary changes to your Edge Delivery Services in AEM.

  1. Sign into the AEM author instance and go to ToolsCloud ServicesEdge Delivery Services Configuration and select the configuration that was automatically created for your site and tap or click Properties in the tool bar.
  2. In the Edge Delivery Services Configuration window, change project type to aem.live with repoless config setup and tap or click Save & Close.
  3. Return to your site using the Universal Editor and ensure that it still renders properly.
  4. Modify some of your content and re-publish.
  5. Visit your published site at https://main--<your-aem-project>--<your-github-org>.aem.page/ and verify that the changes are properly reflected.

Your project is now set up for repoless use.

Troubleshooting

The most common issue encountered after configuring the repoless use case is that pages in the Universal Editor no longer render or you receive a white page or a generic AEM as a Cloud Service error message. In such cases:

Repoless use cases

Now that your base site is configured for repoless usage, you can create additional sites that leverage the same code base.

Multi site management with AEM authoring as your content source

Create sites for multiple languages and markets from the same source documents

Repoless stage and prod environments with AEM authoring as your content source

Use repoless to manage multiple environments

Configuring site authentication for AEM authoring as your content source

When you author using AEM Sites and Universal Editor, you also must enable it in your AEM environment.