Tree structure:
/sitecore
/content
/foo-site
/home
/my-account
/bar-site
/home
/my-account
/baz-site
/home
/my-account
foo-site, bar-site, baz-site) is named Site Node.home, home, home) is named Homepagemy-account, my-account, my-account) is named User Account PageCurrent Item:
The current item could be the home item or any page underneath the home item for any of the given sites, and this query will still work (provided that there are no items with the Homepage template underneath the home items that are an ancestor of the current item).
Query:
query:./ancestor-or-self::*[@@templatename='Homepage']/*[@@templatename='my-account']
Result:
If querying from the home item or one of its descendants in the foo-site site:
/sitecore/content/foo-site/home/my-account
If querying from the home item or one of its descendants in the bar-site site:
/sitecore/content/bar-site/home/my-account
If querying from the home item or one of its descendants in the baz-site site:
/sitecore/content/baz-site/home/my-account