Relative content path for Hippo bean

Hi all,

When I invoke getPath() on a Hippo bean this always results a absolute path, for example: /content/documents/languages/english/homepage/homepage.

I’m looking for a safe way to get the relative content path from a Hippo bean, in the above example this would be:

I want to use this relative content path to append it to the content path of another mount, to retrieve it from there.

Hopefully someone has the answer to this.

Thanks, Philippe.

A HippoBean does not have a relative content path because it isn’t coupled to a site. What has a relative content path is the sitemap item. So you can:


You can similarly get the site content base path from the the request context.

Hi Jasper,

Thanks for your fast answer.

Maybe the relative content path isn’t the right term to describe it. In fact I want to strip the content path from the absolute path of a bean.

In the meanwhile I’ve implemented the following:

public String getRelativeContentPath(HippoBean hippoBean) {
    VirtualHost virtualHost = hippoRequestContextService.getResolvedMount().getMount().
    Map<String, Channel> channels = virtualHost.getVirtualHosts().getChannels(virtualHost.getHostGroupName());
    for (Channel channel : channels.values()) {
        String path = hippoBean.getPath();
        String contentRoot = channel.getContentRoot();
        if (path.startsWith(contentRoot)) {
	        return path.replace(contentRoot + "/", StringUtils.EMPTY);

    return null;

When I invoke this methode with a bean with the absolute path:

a prerequisite is of course that there is a channel with a content root:

The return value is:

Using this ‘relative content path’ I can retrieve the Hippo bean with the ObjectBeanManager, when appending it to the content root of another Channel.

I think this makes things more clean. Would there be a better/more efficient alternative to achieve this?

Thanks in advance!


public String getRelativeContentPath(HippoBean hippoBean) {
    final String baseContentPath = RequestContextProvider.get().getResolvedMount().getMount().getContentPath();
    return StringUtils.removeStart(hippoBean.getPath(), baseContentPath + "/");


Thanks for your reply Woonsan.

In my scenario I have a Hippo bean which is selected using a link picker in a document in the Content Perspective, which can be selected from any content root. Therefore I cannot rely on the request context and have I chosen to loop over the content paths of all Channels.

Does this make sense? Or might there be other alternatives?

Regards, Philippe.

A relative content path has meaning only in the site. A document can be used anywhere on any channel, at least from our perspective. Talking about the relative content path of a document makes no sense from our view. So your way is the only way from the context you are talking about.