SharePoint Bookmark Anchor tag

Have you ever thought to yourself “I need an anchor tag in my SharePoint navigation and that must be easy”.  You blissfully open your SharePoint page, create your anchor tag link, then without a thought go into site settings, go into navigation, set the link.  Then you click your link, and much to your dismay, SharePoint stripped it!  What gives? 

There are multiple ways for you to achieve anchor tag nirvana in SharePoint, but they all aren’t ideal.  I’m going to show you a little trick I stumbled across that is SUPER simple and it works with no code!  Did I mention this works in Office 365?

The Problem

First thing you do is you will create your normal anchor tags on a wiki page by either editing the code and adding <a name="anchor1"></a>, or insert a hyperlink then edit it to access the bookmark option in the ribbon.  Now we go into the navigation settings, and create a navigation link like:

/sites/subsite/sitepages/page.aspx#anchor

When you check the link, it won’t work and you will notice that the anchor tag is removed. 

Less Than the Best Solutions

Here are a few ways I’ve seen to fix this issue and create functioning anchor tags:

  1. Use code in a content editor / snippet web part with JavaScript
  2. Use metadata navigation instead of the structural navigation

These are fine I guess, but I hate code and I don’t like to clutter the taxonomy store unnecessarily.

The Best Way

When you link to your page and anchor, just add the question mark in front of the anchor tag like:

https://contoso.sharepoint.com/sites/subsite/sitepages/page.aspx?#anchor

That’s it!  I love when there’s actually an easy button!