When you build your navigation links in SharePoint, you often have to create links to other SharePoint sites, lists or document libraries. This post is about some quick but very important tips on how to properly link to those entities in SharePoint.
Before we proceed, I recommend that you read this article, that explains what the SharePoint URL is all about. This will help you understand the reasons for what I am about to state below.
Links to Sites
If you look at the URL of a given SharePoint site you are on, you will see something like this:
So when you send this URL to someone or use it for navigation, you probably just copy and paste the whole string, correct? The best practice though would be to omit the /SitePages/page-name.aspx part and just link to https:/companyname.sharepoint.com/sites/site-name. Let me explain.
When you link to the full address, you link to a specific page on that site. But what if the site owner created another page and made it the homepage? Now you will be sending your users to the wrong address (old page). When you just go to the root of the site, SharePoint automatically resolves the homepage and displays accordingly. Hope it makes sense.
This is especially relevant with the evolution of modern pages. As old SharePoint sites are being upgraded to modern look and feel, you will have new pages (read: new URL). That means that if you linked to the old page/URL somewhere in your Intranet, your visitors will never see the modern page you worked on for so long. :-( (want to thank my loyal blog follower, MG from Virginia, USA for this specific use case).
Links to lists and libraries
The same approach applies to the lists and libraries. As an example, here is a normal address of a document library:
and here is one for a list:
AllItems.aspx points you to the specific view within a library or a list, respectively. But what if you created a new view on the list or library that groups and sorts by some metadata column and made that view a default one? Same as with the site, you will now send your users to the wrong URL (view). Just like with sites, best practice would be to point just to the root of a list (https://companyname.sharepoint.com/sites/site-name/Lists/list-name) or a library (https://companyname.sharepoint.com/sites/site-name/Shared%20Documents). Let SharePoint resolve and figure out automatically which view is the default one.