The Adobe Experience Manager (AEM) REST API makes it easy to script content operations from the terminal shell. It’s not appropriate for production content but is tremendously useful for website content migration; for tasks like a bulk import of simple articles it can save a metric buttload of manual effort.

Assuming a data file (CSV, XML, JSON, etc.) listing the pages with attributes such as path, title, etc, and perhaps individual files holding the HTML content, the general technique would be:

  • Create manually an empty page to use as a template
  • Loop through the data file, copying the template page to the relevant location and updating its name, title, content, etc.

Apache Sling documentation is relevant.

Create a page

curl -u admin:admin -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:primaryType=cq:PageContent" -F "jcr:content/jcr:title=New Page" -F "jcr:content/sling:resourceType=/apps/myapp/components/page-standard"  -F "jcr:content/cq:template=/apps/myapp/templates/page-standard" http://localhost:4502/content/mywebsite/mypage

Copy or move a page

Copy a node, for example to duplicate a page:

curl -u admin:admin -F:operation=copy -F:dest=/content/mywebsite/en/mynewpage http://localhost:4502/content/mywebsite/en/mypage

In the example above, change -F:operation=copy to -F:operation=move to move rather than copy the page.

Update a page

Update a node attribute value, for example the text property of a text-image component, by specifying the value directly:

curl -u admin:admin --data 'text=<p>Some text</p>' http://localhost:4502/content/mywebsite/en/mypage/jcr:content/par/text-image

Update a node attribute value, for example the text property of a text-image component, by reading the value from a file:

curl -u admin:admin --data-urlencode  text@somefile.txt http://localhost:4502/content/mywebsite/en/mypage/jcr:content/par/text-image