Google Docs – Add Relative Link to Header Using URL Fragment

google docs

I already know how to add links via Bookmarks and Table of Contents. I also know how to directly link to a header

However, rather than pasting the entire URL for the header, which creates an absolute link to that specific Google Doc, I want to just paste the fragment (#header=h.abc123xyz). This has the benefit of being document relative, in the sense that if someone makes a copy of my document, saves it as an HTML page, etc. (thus changing the URL), the anchor will still work as expected in the new document. Currently, it would just link to the section of the original document.

Is this possible?

Note: I've tried just pasting the fragment in the regular Insert Link dialog, but Google thinks it's an invalid URL. Is there a workaround? Am I doing it wrong?

Best Answer

If I click Insert / Link... and put in #header=h.abc123xyz, when I save it as an HTML document it is converted to #h.abc123xyz and it works as expected.