0

I have a SharePoint Online page created with a template, which I cannot remove the left navigation pane from. (I can edit the list of links, but I want to remove the whole pane completely).

Ideally I would like to remove the left navigation panel from this page only. Not from the entire site.

Please suggest any workaround...

2 Answers 2

0

If you are using a modern SharePoint site, you can disable the Quick Launch by going to Site Settings > Navigation elements (under "Look and Feel") > Untick "Enable Quick Launch".

More information can be found in the article below, in the section "Turn the left-hand menu on or off for a SharePoint team site":

https://support.microsoft.com/en-us/office/customize-the-navigation-on-your-sharepoint-site-3cd61ae7-a9ed-4e1e-bf6d-4655f0bf25ca

0

You could add js code to determine whether the page is the target page.If it is,then add the custom css(Use CSS to hide left navigation).

Demo:

if ((window.location.href.toLowerCase().indexOf('testfolder') > 0))
    {        
        var head = document.getElementsByTagName('head')[0];
        var link = document.createElement('link');
        link.href = 'https://contoso.sharepoint.com/sites/dev/Doc/testFolder/test.css';
        link.rel = 'stylesheet';
        link.type = 'text/css';
        head.appendChild(link);
    }

Inserting this code needs to distinguish different types of pages:

  1. Modern page:you need to use SPFX Extension to add JS file.
  2. Classic page:you could add this file to global jslink.

pnp powershell:

$username = "[email protected]"
$password = "Password"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/dev -Credentials $cred
 Add-PnPJavaScriptLink -Name "JSLoadAfterSP" -Url /sites/dev/Doc/testFolder/test.js -Sequence 9999 -Scope Site

Similar issue:

How to use JS to inject CSS for specific system pages

https://docs.microsoft.com/en-us/answers/questions/70373/customization-colour-document-header.html

SPFX Extension add js file:

https://github.com/Amos-IT/SharePoint-FrameWork-Demos/tree/master/react-application-injectjs-master

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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