Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Is there a way to read out the site root page dynamically depending on the site the page is placed in?

varunmitra
Level 3
Level 3

Yes, you can easily access the website root with the help of Page object. You can directly call getAbsoluteParent method to access the root page at a level of your choice.

Code snippet for the component would look like:

Sightly HTML code snippet:

<div data-sly-use.contentJS="content.js">

    ${contentJS.parentPage.path}

    </div>

Content.js

use(function() {

    return {

      parentPage: currentPage.getAbsoluteParent(1)

     };

});

0 Replies