# Link to anchor in another document

**URL:** <https://community.bloomreach.com/t/link-to-anchor-in-another-document/383>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [September 7, 2018, 1:24pm UTC](https://community.bloomreach.com/t/link-to-anchor-in-another-document/383 "2018-09-07T13:24:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![katie](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/katie/32/1479_2.png) [@katie](https://community.bloomreach.com/u/katie)\
**Post date:** [September 7, 2018, 1:24pm UTC](https://community.bloomreach.com/t/link-to-anchor-in-another-document/383/1 "2018-09-07T13:24:09Z")

</div>

I’ve written a migration to import a large number of HTML pages into documents within the CMS. The documents are all chapters and sections of a larger overall document.

They all display fine, but I’m having an issue with anchor links, which work fine when the anchor is on the same page (as per the details given here: [https://www.onehippo.org/library/end-user-manual/editing-a-document.html](https://www.onehippo.org/library/end-user-manual/editing-a-document.html)) but all of the documents need to link to the anchors on a single document, which is an appendix of terms referenced throughout the rest of the overall document.

If you add the anchor onto the link via the code (i.e. `<a href"appendix#anchor">some anchor</a>` the link goes to pagenotfound. Is there a way of allowing links to anchors in other documents?

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [September 7, 2018, 1:59pm UTC](https://community.bloomreach.com/t/link-to-anchor-in-another-document/383/2 "2018-09-07T13:59:26Z")

</div>

It seems like a shortcoming at the moment.  
I see `org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter#rewriteDocumentLink(String, Node, HstRequestContext, Mount)` doesn’t care if the `href` (assumed to be a document path) contains a `#`.  
I think it can be improved. Feel free to file a ticket in [https://issues.onehippo.com/projects/HSTTWO](https://issues.onehippo.com/projects/HSTTWO).  
In the short term, you might also consider implementing a custom content rewriter [1] which trim off `#...` part before invoking `#getDocumentLink(...)` and appending it to the result.

Regards,

Woonsan

[1] [https://www.onehippo.org/library/concepts/rewriting-rich-text-field-runtime/hst-2-rewriting-rich-text-field-runtime.html](https://www.onehippo.org/library/concepts/rewriting-rich-text-field-runtime/hst-2-rewriting-rich-text-field-runtime.html)
