Edge Delivery Services how-tos · updated
How an Edge Delivery Services block works: folder, markup and decorate()
An Edge Delivery Services block is a folder under /blocks named after the block. It holds a CSS file and a JavaScript module with the same name, and the block loader adds the files when an author uses that block on a page. The JavaScript module exports a default function that receives the block element and rewrites the nested div markup into the structure you want to style.
What the author creates
In Word, Google Docs or Document Authoring, an author adds a table whose first row holds the block name, for example 'Cards'. The rows and cells below become the block's content. On the server this is rendered as nested div elements: one div with the block's class, a div per row and a div per cell. In the simplest case a block has a single cell.
What the developer writes
The block name is used three ways: as the folder name, as the CSS and JS file names, and as the CSS class on the block element. aem.live describes the JavaScript as an ES module whose default export runs when the block loads. Keep every CSS selector scoped to the block class so styles never leak into other blocks.
| Part | Where it lives | Example for a 'cards' block |
|---|---|---|
| Folder | /blocks/<name>/ | /blocks/cards/ |
| Styles | /blocks/<name>/<name>.css | /blocks/cards/cards.css, selectors start with .cards |
| Behaviour | /blocks/<name>/<name>.js | export default function decorate(block) { … } |
| Markup class | Added from the table header | <div class="cards"> |
Adobe's guidance is to absorb complexity in code rather than pushing it onto authors: an author should be able to copy and paste a block and understand it. Prefer simple semantic markup plus modest DOM changes over very complex CSS selectors.
Illustrative decorate() for a cards block (turns rows into a list)
export default function decorate(block) {
const ul = document.createElement('ul');
[...block.children].forEach((row) => {
const li = document.createElement('li');
while (row.firstElementChild) li.append(row.firstElementChild);
ul.append(li);
});
block.replaceChildren(ul);
}How to do it
- Agree the block's authoring table with authors first: name, rows and what each cell holds.
- Create /blocks/<name>/<name>.css and <name>.js with the same name as the table header (lower case, hyphenated).
- In the JS, export a default function that takes the block element and reshapes its rows and cells.
- Scope every CSS selector with the block class.
- Preview a page that uses the block and check the decorated DOM in the browser's dev tools.
Related pages on this site
Questions
Can blocks be nested inside other blocks?
aem.live says blocks should never be nested because it makes authoring very hard. Use sections, or have one block reference content another way.
Does every block need JavaScript?
No. Some blocks only need CSS on the default markup; add JS when you need to restructure the DOM or add behaviour.
Where does a block's name come from?
From the first row of the author's table. It becomes the folder name, the file names and the CSS class.
Sources
- aem.live: Markup, Sections, Blocks, and Auto Blocking (checked 10 Nov 2026)
- aem.live: The Anatomy of a Project (checked 10 Nov 2026)
- aem.live: Developer Tutorial (checked 10 Nov 2026)
Facts about Adobe's platform are from the linked Adobe pages, checked 10 Nov 2026. Explanations and examples are ours unless marked as Adobe's.