SharePoint Online: How to Get Direct Link to a Document In Modern Libraries?

Requirement: Get the direct link to a document in SharePoint Online.

I need to share a document with someone but don’t want them to have to navigate through my SharePoint Online site. How do I find the URL for a SharePoint document? Well, there is an easy way to do this! This blog post will show you how to get a direct link to a document in SharePoint Online.

Unlike SharePoint Online’s classic experience, modern document libraries don’t provide a direct link to documents. However, here are the tricks to get a direct link to the file:

  1. Navigate to your SharePoint Online document library, select the file, and click on “Copy Link” from the toolbar.
  2. In the link settings popup, select “People with existing access” and click on Apply.
  3. That gets you the link something like: https://Crescent.sharepoint.com/:w:/r/Documents/2018/ComplianceDeclaration.xlsx?d=wfd7f94f6baf55c2eaeb7e906ebd7ffb5&csf=1&e=Yys7gY
  4. Remove everything from ?d= and remove /:w:/r (sometimes :/x) and the direct link will be: https://Crescent.sharepoint.com/Documents/2018/ComplianceDeclaration.xlsx

However, this method breaks the permission inheritance of the file!

If you have Version history enabled, you can copy the direct link from the latest version of a file. 

sharepoint online direct download link

Method 3: Get the Direct URL of a Document in SharePoint Online from the Document Information Panel

Here is another way to get the direct URL of any file in SharePoint Online. Just select the file >> Open the document information panel by clicking on the “i” icon and clicking on the little copy icon under “Path”! This gets you the direct URL of the document in your clipboard!

get direct link to documents in sharepoint online

This method also works for Folders!

These direct links can be shared with anyone who has permission to access the document, and it can be used to quickly and easily access the document from any location.

How do I find the URL of a SharePoint Online Site?

Open any link to your SharePoint Online site in the web browser >> Click on the “Home” link in the navigation (or the icon for the site at the top-left). Now, you can obtain the site URL from your web browser’s address bar. Typically, it looks like: https://YourDomain.SharePoint.com/sites/YourSiteURL

How do I find the URL of a SharePoint folder?

Navigate to the SharePoint Online Folder in Web Browser >> Click on the “i” icon to open the details pane. Scroll down and click on the little copy icon next to “Path”.

How do I find the document library URL in SharePoint?

Open your SharePoint Online site in Web Browser >> navigate to your Document Library >> Copy the URL in your browser. Typically, it looks like this: https://YourDomain.sharepoint.com/sites/YourSite/Shared%20Documents/Forms/AllItems.aspx. You can get the document library URL anything in front of “/Forms/”. (“https://YourDomain.sharepoint.com/sites/YourSite/Shared%20Documents”, in this case.)

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

10 thoughts on “SharePoint Online: How to Get Direct Link to a Document In Modern Libraries?

  • HI. I got a problem by my sharepoint. There are some files (PDF) in my sharepoint Website, as I want to open it, I get 404 Error (it means that the file is not found), I have checked the Path and it is the right path. I have changed the path with the same path and this time it was opened with out any problem. If it was the problem of one file, could not be a big problem but when it is the problem of 1000 file it is. Can any one help me with this issue

    Reply
  • Hi Rajack,

    I’m currently working through integration with Salesforce relating to files stored in SPO for my employer where I have a requirement to be able to encode URLs to use the permalink path, not the list/library-specific path.

    I do believe that your example is not referencing the file’s permalink since it is encoding the List/library under which it resides.

    In my scenario, I am looking to re-encode a URL that is not, list-specific, thus allowing for the file to be moved between lists without any impact on the user/front-end encoded URL for the said file.

    For example:
    Document ID/Permalink path: https://{mytenant}.sharepoint.com/sites/{mysite}/_layouts/15/DocIdRedir.aspx?ID=UJE6U3J7S4E7-919052688-11
    Your method: https://{mytenant}.sharepoint.com/sites/{mysite}/Controlled%20Documents/dima%20test%2022%20june%20v8%20a0I1X00000Xu4X2UAJ.pdf

    The first URL resolves to the second URL, which lists the library name “Controlled Documents”. You could argue that this makes the second URL the permalink, but the second URL is tied to the list/library and when the file is moved to another library, it is no longer valid, whereas the first URL, resolves in all cases, provided the file resides within the same site/instance.

    I believe that there must be a way to reconstruct a URL that is not anchored to the site too, given that the Document ID in SPO remains valid for the document irrespective of which site and library the document is migrated to. There is some underlying mechanism that re-encodes the permalink URL when the file is moved from Site 1 to Site 2, such that the Document ID resolves to the new location when calling the file through the Document ID link.

    I would like to establish if a list and site-agnostic permalink can be constructed or reconstructed for a given file. I’m still researching this possibility.

    I have a genuine requirement to place a file in one of four sites on Day 1, but subsequently have the file moved by a user based on some criteria to one of 3 other predefined sites. My ideal scenario is one where on my front end (from where the file is originally uploaded into a given SP site+list) the URL that is encoded for the file (as a subprocess or a follow-up cron job) is one that can accommodate the file moving between 3-4 sites, without breaking access to the file.

    Any pointers for research or consideration will be welcome.

    Reply
  • I used method 3 but I always get a warning dialog box
    Open this file?
    Do you want to open XXXX.xlsm from site.com
    Report file as unsafe
    Open Cancel
    is there a way for SP not to show this since all files are internal and safe within the organziation

    Reply
  • What happens if using Method 1 but not editing the link at all? I mean, just making the Copy Link and share that URL (with all its arguments and with the :w:/r part).
    Is it necessary to edit the link obtained with Copy Link?
    Thanks for answering.

    Reply
  • I would like to know how to link to a file/folder on the internal/local drive? This used to be possible via quick links and then as an insert link, but now it is not working (http needed). Help??

    Reply
  • Both methods don’t seem to work anymore 🙁
    At least not for image files.

    Would be glad to hear about any new way anyone is aware of!

    Reply
    • Hi David, Confirmed all the above methods just works fine. Let me know what’s the difficulty you are facing.

      Reply
  • One enormous difference between the two methods described above: in my testing, “Copy link” causes SharePoint to break inheritance for the document’s permissions, which violates Microsoft’s own recommended best practice and potentially creates long-term permissions havoc. Copying the link from Version history, on the other hand, produces a very clean, human-readable link without modifying the document’s permissions.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *