Author the header page
Before developing the header block, first author its content in the Universal Editor to have something to develop against.
The header content lives in a dedicated AEM page named nav
.
To author the header:
-
Open the
nav
page in the Universal Editor -
Replace the default button with an Image block containing the WKND logo
-
Update the navigation menu in the Text block by:
- Adding your desired navigation links
- Creating sub-navigation items where needed
- Setting all links to the home page (
/
) for now
Publish to preview
With the Header page updated, publish the page to preview.
Since the header content lives on its own page (the nav
page), you must publish that page specifically for header changes to take effect. Publishing other pages that use the header will not update the header content on Edge Delivery Services.
Block HTML
To begin block development, start by reviewing the DOM structure exposed by the Edge Delivery Services preview. The DOM is enhanced with JavaScript and styled with CSS, providing the foundation for building and customizing the block.
Because the header is loaded as a fragment, we need to examine the HTML returned by the XHR request after it’s been injected into the DOM and decorated via loadFragment()
. This can be done by inspecting the DOM in the browser’s developer tools.
The following is the header page’s HTML after it has been loaded using the provided header.js
and injected into the DOM:
To find and inspect the page’s <header>
element in the web browser’s developer tools.
Block JavaScript
The /blocks/header/header.js
file from the AEM Boilerplate XWalk project template provides JavaScript for navigation, including dropdown menus and a responsive mobile view.
While the header.js
script is often heavily customized to match a site’s design, it’s essential to retain the first lines in decorate()
, which retrieve and process the header page fragment.
/blocks/header/header.js
The remaining code can be modified to fit your project’s needs.
Depending on the header requirements, the boilerplate code can be adjusted or removed. In this tutorial, we’ll use the provided code and enhance it by adding a hyperlink around the first authored image, linking it to the site’s home page.
The template’s code processes the header page fragment, assuming it consists of three sections in the following order:
- Brand section – Contains the logo and is styled with the
.nav-brand
class. - Sections section – Defines the site’s main menu and is styled with
.nav-sections
. - Tools section – Includes elements like search, login/logout, and profile, styled with
.nav-tools
.
To hyperlink the logo image to the home page, we update the block JavaScript as follows:
The updated code wrapping the logo image with a link to the site’s homepage (/
) is shown below:
/blocks/header/header.js
Below is the original header.js
generated from the template:
/blocks/header/header.js
Block CSS
Update the /blocks/header/header.css
to style it in accordance to WKND’s brand.
We will add the custom CSS to the bottom of header.css
to make the tutorial changes easier to see and understand. While these styles could be integrated directly into the template’s CSS rules, keeping them separate helps illustrate what was modified.
Since we are adding our new rules after the original set, we’ll wrap them with a header .header.block nav
CSS selector to ensure they take precedence over the template rules.
/blocks/header/header.css
Development preview
As the CSS and JavaScript are developed, the AEM CLI’s local development environment hot-reloads the changes, allowing for quick and easy visualization of how code impacts the block. Hover over the CTA and verify the teaser’s image zooms in and out.
Lint your code
Make sure to frequently lint your code changes to keep it clean and consistent. Regular linting helps catch issues early, reducing overall development time. Remember, you cannot merge your development work into the main
branch until all linting issues are resolved!
Preview in Universal Editor
To view changes in AEM’s Universal Editor, add, commit, and push them to the Git repository branch used by the Universal Editor. Doing so ensures that the block implementation does not disrupt the authoring experience.
Now, the changes are visible in the Universal Editor when using the ?ref=header-and-footer
query parameter.
Footer
Like the header, the footer content is authored on a dedicated AEM page - in this case, the Footer page (footer
). The footer follows the same pattern of being loaded as a fragment and decorated with CSS and JavaScript.
The footer should be implemented with a three-column layout containing:
- A left column featuring a promotion (image and text)
- A middle column with navigation links
- A right column with social media links
- A row at the bottom spanning all three columns with the copyright
Use columns block in the Footer page to create the three-column effect.
Column 1 | Column 2 | Column 3 |
---|---|---|
Image | Heading 3 | Heading 3 |
Text | List of links | List of links |
The CSS below styles the footer block with a three-column layout, consistent spacing, and typography. The footer implementation uses only the JavaScript provided by the template.
/blocks/footer/footer.css
Congratulations!
You’ve now explored how headers and footers are managed and developed in Edge Delivery Services and Universal Editor. You’ve learned how they are:
- Authored on dedicated AEM pages separate from the main content
- Loaded asynchronously as fragments to enable independent updates
- Decorated with JavaScript and CSS to create responsive navigation experiences
- Integrated seamlessly with the Universal Editor for easy content management
This pattern provides a flexible and maintainable approach for implementing site-wide navigation components.
For more best practices and advanced techniques, check out the Universal Editor documentation.
More help on this topic
The Perfect Blend: A New Era of Collaboration with AEM and Workfront
Adobe Customer Success Webinars
Wednesday, Apr 2, 5:00 PM UTC
Explore how Adobe Experience Manager and Workfront integrate to help teams move from ideation to delivery without the usual bottlenecks, ensuring content is organized, on-brand, and ready to go live faster.
RegisterAdobe Experience Manager Sites at Summit
Register for these developer sessions:
- The True Cost of a Failed Implementation (attend online)
- B2B Reimagined: Transforming Go-to-Market Strategies for Profitable Growth (attend online)
- Rapid Feature Releases with AEM Cloud: Telegraph Media Group’s RDE Strategy (attend online)
- Elevate and Empower Teams with Agentic AI for Exceptional Experiences (attend online)
- Adobe Experience Manager Sites: Top Innovations (attend online)
Connect with Experience League at Summit!
Get front-row access to top sessions, hands-on activities, and networking—wherever you are!
Learn more