How can we help you today?

How to Create an Anchor Link That Opens to a Specific Paragraph on a SharePoint Page

This article will showcase how you can create a direct link that is anchored to a specific Paragraph on a SharePoint page. Simply follow the steps outlined in this solution article to learn how.


sample anchor link


NOTEIf you wish to create an anchor link for a specific Section or Design Element, check out How to Create an Anchor Link That Opens Specific Content on a SharePoint Page.

TABLE OF CONTENTS


Prerequisites


Step-by-step Tutorial

Follow the steps below to learn how to create anchor links:


Step 1: Edit the ShortPoint Web Part

Go to the SharePoint page you want to use and click Edit:


Edit


Close the Toolbox:


close icon


Edit the ShortPoint web part:


Edit properties icon


Step 2: Switch to Grid Mode

NOTEBefore proceeding, make sure you already have a Text Design Element with paragraphs inside. In our example below, we want to be redirected to the highlighted paragraph: 

sample Text Design Element


Click the Switch to Grid Mode icon:


Switch to Grid Mode icon


Step 3: Open Code View

Hover over the Text Design Element you want to use and click the cogwheel icon:


cogwheel icon


Click the down icon:


down icon


Select the Code View icon:


code view icon


Step 4: Add a Unique ID

Look for the paragraph you want to use. Notice that you’ll see <p at the start:


<p


Right after <p, write id=”unique-id”.


NOTEYou can replace unique-id with any name you want. In our case, we used traveler. Make sure to take note of it as you will need it to create the Anchor link.


write id


Then, click the Code View icon again:


code view icon


Once satisfied, click Update:


Update


Step 5: Add the Code Design Element

Click the plus icon to open the library of Design Elements:


plus icon


Look for Code and select it:


Code


Step 6: Copy the JavaScript Code

Copy the JavaScript Code below:

(function() {
    let i = 0;
    
    function scrollIntoView() {    
        i++;
        let hash = window.location.hash;
        if (typeof (hash) == 'string' && hash.includes('#')) {
            let elem = document.getElementById(hash.substring(1));
            if (elem != null) {
                clearInterval(myInterval);
                elem.scrollIntoView({
                    block: 'center',
                    behavior: 'smooth'
                });
            }
            if (i === 300) 
                clearInterval(myInterval);
        }
    }
    
    let myInterval = setInterval(scrollIntoView, 2000)
})()



You can customize the following values:

  •  block value  - controls the vertical alignment of the element within the scrollable ancestor container. You can learn more about the values you can add in the Element: scrollIntoView() method.
  • setInterval value - specify the number of seconds before the page scrolls down to the specific item you set. Currently, the setInterval’s value is 2000, which equals 2 seconds.

Step 7: Paste the code

Paste the code in the JavaScript field:


paste code


NOTEMake sure you disable Sandbox Mode: 

disable sandbox mode


Click Insert:


Insert


Step 8: Save

Click the eye icon to see your page in real-time:


eye icon


Save your changes:


Save


Follow this format to create the Anchor link:

https://<page URL>#<IDName>


In our example, the URL we will share is:

https://my.sharepoint.com/#traveler


Where:

  • Page URL is https://my.sharepoint.com/
  • # is the symbol for a hashtag
  • ID  is traveler

You now have a shareable URL that you can provide to your users to direct them to a specific paragraph on your intranet page:


sample anchor link


BONUS TIP: You can use your anchor links to create a useful navigation menu on your page. Simply add the link on a Design Element that allows URL linking. In our example, we used Tiles: 

anchor link navigation

Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 90 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more