21

In Sharepoint (2010) wiki pages it is easy enough to add a hyperlink, but how can one add a hyperlink anchor without editing the messy html?

You can see here that, although I've got a link and typed in an anchor into the bookmark field, it complains. I can save it, and it seems to remember what I put there, but when I try to use it by linking to the anchor, it doesn't jump (that is, <a href="#anchor1">jump</a> doesn't work).

I've looked over this tutorial, but it doesn't seem to work.

enter image description here

But the blurb there in the screenshot says, "You can make hyperlinks that jump directly to a bookmarked location" - okay, fine, well, how do I do that?

  • has anyone had luck creating bookmarks like this within easy tabs? I am having problems doing so. – user51373 Feb 16 '16 at 21:50
  • Has anyone had the experience of the link changing to design mode? I've had inconsistencies to the point I've removed the bookmarks for now. I set them up the way it was described here, not once, but multiple times. I'd save, test, they'd work. I'd come back, click on them, a link might still work or it might have had the url changed to go into design mode (ooh...not good)... or it just didn't work at all. – Rita Tice Seaton Mar 27 at 20:23
17

I have managed to make this work by combining the information here and here.

  • To enable the bookmark functionality you need to get an admin to enable SharePoint Server Publishing Infrastructure feature on the site collection level and then the SharePoint Server Publishing feature must be activated on the site level.

    1. Start by selecting the text that you want the link to point to.
      Link selection

    2. Insert a new link From Address
      Insert new hyperlink

    3. Paste the current page address in the Address field Paste destination address

    4. Add your bookmark name (without the hash) Add bookmark name

    5. Select the text that should point to your bookmark and insert a new link From Address Insert new hyperlink

    6. Type the name of the destination bookmark (don't forget the hash) Add name of destination bookmark

    7. Save the page

  • Your answer creates a hyperlink TO a destination. The question I asked was how to add the anchor - how do you add the DESTINATION in the first place? – bgmCoder Mar 3 '14 at 15:24
  • 1
    The anchor is added in step 4 – MoonSire Mar 4 '14 at 6:14
  • 1
    Ah, you got me on that, sorry! It does seem to work - I can't believe it. I spent hours on that. The trick was creating the hyperlink anchor with the page address as the hyperlink destination. This is a better solution than mine, so I'm marking yours correct. Thank you! – bgmCoder Mar 4 '14 at 15:08
  • I would like to thank the person who posted the answer to the bookmark question as he saved me a lot of time - thanks for sharing the tip. I had problems adding a simple bookmark to my page and only worked after reading this post. THANK YOU HEAPS Basem Sydney - Australia – user30186 Jul 2 '14 at 2:58
  • 1
    By the way this also works in 2013 and higher versions of SharePoint. Thank you! – Chris G Apr 4 '17 at 14:59
7

The only way to do it is use an anchor tag in the code:

<a name="MyAnchor"></a>

Then add a hyperlink to the page the anchor is on, but include #MyAnchor:

http://mysite.com/wiki/page.aspx#MyAnchor

If there's a better way, let me know.

  • 1
    Yeah, I don't want to do it in the code. I've folks whose mind would leave their body if I asked them to edit code. Besides, the code-editor is quite unwieldy. – bgmCoder Jul 17 '13 at 4:17
  • Okay, there is a better way... :) – bgmCoder Jul 17 '13 at 22:26
  • May not have answered the OP's question but I ended up here when looking to do exactly this so thanks for sharing. – RyanfaeScotland Feb 3 '15 at 10:43
1

Ah, here is a way.

The idea is that the user using the wiki editor will create a new hyperlink and use a special token to denote an anchor. In my example, the token is /__

I chose that because the hyperlink has to start with something that the editor would accept - and it will accept a /. Also, because it is very rare to see a hyperlink with /__ anywhere in the string.

Thus, the user would use the regular wiki richtext editor, then use the "insert hyperlink" button, and specify a hyperlink like this:

/__myanchor

The function

This needs to be added in a Content Editor or in the master page somewhere. The function will look for that pattern and add a hyperlink name based on the specified link that was given, and then remove the false hyperlink (where the optional parameter specifies a # which causes it to be a hyperlink to that same page, which means it doesn't cause any navigation), or, if the parameter is specified, it will supply that url as a default.

function WikiLinks(defaulthyperlink){
    if(!defaulthyperlink)
          defaulthyperlink = "#";
    $(".ms-wikicontent a").each(function(){
        var thishref = $(this).attr('href');    
        if(thishref.indexOf('/__') >= 0){
            thisanchor = String(thishref).substring(3, String(thishref).length);            
            $(this).attr('name', thisanchor );
            $(this).attr('href',defaulthyperlink);
        }
    }); 
}

If you decide to use a different token, make sure the change the length in the thisanchor substring search.

[update]

The catch to this is that you must call the function after the UI is loaded. This means that the function works (like a charm) only within a single page. You can't use it to link to an anchor in another page because the linkage fires before the script gets to add the anchor name.

  • Did this work for you? – TempaC Jul 19 '13 at 7:40
  • 1
    Yes, it works as long as you load the function after the UI is loaded, but it only works within a single page. You can't link to anchours in other pages. I'll explain in my answer. – bgmCoder Jul 19 '13 at 13:43
0

The wiki editor could make this easier :-)

This method works for me...

  1. Highlight a word in the header where you want to insert an anchor; then copy the word
  2. Press Ctrl-K. In my instance default text appears in the address field "/site/site/", click OK to accept the default
  3. You'll notice that a Link Tools ribbon appears. Paste the anchor name into the anchor field
  4. Go to your link text and highlight it; then insert a link "from address." Add "#" and paste again.

I have no idea if this will work in your case. Step 2 is weird. But it's the only way that I can invoke the "link tools" ribbon. Too bad this isn't part of the Link options from the get go.

[[EDIT: I didn't notice this before but SharePoint inserts the anchor/id AND a href link and there's nothing you can do about it except edit the HTML so my answer isn't much of a solution, unfortuntately.]]

  • 1
    Sorry so slow to respond... No, editing the html is not the answer. I tried your method, but the "bookmark" field is grayed out and it doesn't save. – bgmCoder Jul 17 '13 at 4:13
0

To jump from 'Heading 1' to 'Section 1' on the same wiki page:

Highlight 'Heading 1', insert link 'from address' Text to Display: Heading 1 Address: #Section 1 click ok

then..

Highlight 'Section 1', insert link 'from address' Text to Display: Section 1 Address: # click ok

Highlight 'Section 1' again In Bookmark (in link tab) write: Section 1

Save page.

0

The way I found to create a link to a section (specific heading) on another Wiki page, is as follows:

1) Copy the URL (Ctrl-C) of the Wiki page (to have it ready to do the next step).

2) Create your link on the Wiki page by selecting the heading you wish to link to, such as: Section 2. Then click on the ribbon to insert link, From Address, and paste in the URL of the active Wiki page.

3) Click on the link you just created, and the LINK tab should appear.

4) Enter the Bookmark you want to use, such as: 02

5) Save the page or "Check-in" the page (if your site is using a Workflow process).

6) Go to your other page to create your new link to the Bookmark you just created and click to edit the page.

7) Enter or select the text you want to make your link to, and on the Insert tab, select Link - From Address, and paste the URL of the page you want to link to the specific bookmark (Section 2, for example).

8) At the end of the pasted URL in the link, just add the bookmark reference of that Section 2 with hashtag '#' prefix, which was created on the other Wiki page, in this example: #02. The link should look something like this: https:/mysharepoint/wiki/Pages/Instruction%20Guidelines%20for%20MDO.aspx#02

9) As an option, you can add in the Description box (on the Link tab) the title of the text heading (such as: Section 2). This will create a tooltip on the page when a user hovers over the link to click.

9) Save your page, and test the link. It should go directly to the other Wiki page and to the exact Bookmark for Section 2 (on that page).

-1

This is a rather old post, but hopefully this will help someone else in the future.

In regards to intra-page hyperlinking in SharePoint 2010, I found it is easiest to do through MS Word with book marks, and hyperlinks.

Highlight destination, click Insert> Bookmark. Label Bookmark and hit add. Then highlight your source (what you want to click on to take you to your destination bookmark), click insert> hyperlink> Place in this document > Select your bookmark.

When you copy and paste this into SharePoint 2010, it will work, or at least has for me.

  • 2
    I think you've missed the point - the point was to achieve the inter-page hyperlinking inside a sharepoint WIKI PAGE - not a Word document. The Wiki Page has issues. – bgmCoder Jan 31 '14 at 22:23
  • @TimothyHerlihy Does this action work on a Wiki-page too, and not only a content editor non wiki page/web part? – Benny Skogberg Feb 1 '14 at 2:28
  • It's more like a hack or a workaround rather than a robust solution... – Hitesh Sep 23 '16 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.