This article covers a Bloomreach Experience Manager version 11. There's an updated version available that covers our most recent release.

3 - Handle Internal Links

Previous - Code DiffNext

Reset the workspace to step 3:

git checkout -f step-3

Internal Links

As you have noticed in the previous step internal links inside rich text content are not working in the app. In this step the app is extended with logic to resolve internal links.

Hippo defines internal links as links from one document in the repository to another document in the repository. Authors create them in the CMS by selecting some text in a rich text field and picking the target document. Because Hippo CMS is decoupled from the frontend internal links are stored in a frontend-agnostic manner: they are references to the target document's location in the repository. It is up to the frontend application to properly handle such links.

To help the frontend application do this the Document Detail resource's response includes for each rich text property a links object containing all links referred to in the rich text content.

For example in the response below the rich text property items['myhippoproject:content'].content contains a link <a data-hippo-link=\"workshop\">workshop</a> which refers to items['myhippoproject:content'].links.workshop.

      "myhippoproject:location":"Room 101",
      "myhippoproject:introduction":"Start the day with a nice breakfast.",
         "content":"<p>Breakfast is served starting from 8:00 until 9:30.</p><p>After breakfast it&#39;s time to start the <a data-hippo-link=\"workshop\">workshop</a>.</p>",

Code Changes


The DocumentsController is extended with a function resolveLinks which takes a REST response like above, looks up each internal link and rewrites it to the proper target URL in the app. The processed rich text content is added to the scope so the view can render it.


hippoRestApp.controller('DocumentsController', function($scope, $routeParams,
    DocumentsService, apiPrefix) {

  if (!$routeParams.uuid) {
    DocumentsService.getList().$promise.then(function(response) {
      $scope.documents = response;
  } else {
        response) {
      $scope.document = response;

      // resolve internal links
      $scope.content = $scope.resolveLinks(response);

      // TODO
      // resolve images


  $scope.resolveLinks = function(response) {
    var someElement = document.createElement('div');
    someElement.innerHTML = response.items['myhippoproject:content'].content;
    var links = someElement.querySelectorAll('a[data-hippo-link]');
    for (var index = 0; index < links.length; index++) {
      if (response.items['myhippoproject:content'].links[links[index]
          .getAttribute('data-hippo-link')]) {
        var uuid = response.items['myhippoproject:content'].links[links[index]
        links[index].href = '#/' + uuid;
    return someElement.innerHTML;



The detail view is slightly modified so it renders the processed rich text content instead of the raw property value from the response.


  <div ng-bind-html="content"></div>


  • Use Hippo CMS to include an image in a document's rich text content. See how it's handled in the REST response. The same mechanism is used, and a URL to retrieve the image is included. Can you extend the resolveLinks function so that images in rich text content are also properly rendered? 


In this step the app was extended with logic to resolve internal links in rich text content. Now go to step 4 to learn how to search for documents using the Content REST API.

Previous - Code DiffNext

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?