SharePoint Online:如何使用 PowerShell 隐藏左侧导航栏?
要求:在 SharePoint Online 中隐藏快速启动栏。
如何隐藏 SharePoint Online 中的快速启动?
位于网站左侧的快速启动或左侧导航通常包含指向当前网站中的资源的链接,例如列表和库、子网站等。作为 SharePoint Online 用户,您可能已经注意到左侧导航栏是无论您在哪个页面,始终显示。当您使用列表和库时,这可能会很有帮助,但是,在某些情况下,您可能希望隐藏左侧导航栏以简化用户界面并让您的内容脱颖而出。在本文中,我们将向您展示如何禁用 SharePoint Online 中的左侧导航栏。
要关闭 SharePoint Online 中的快速启动,请转到:
这将删除 SharePoint Online 中的快速启动。
在新式 SharePoint Online 网站中禁用左侧导航(或顶部导航栏)
现代导航选项还允许您关闭 SharePoint Online 网站的导航。
- 登录到您的 SharePoint Online 站点 >> 单击“设置”齿轮
- 单击设置菜单>>中的“更改外观”,然后单击“更改外观”窗格下的“导航”。
- 现在,您可以通过设置“站点导航可见性”开关来启用或禁用导航。
- 单击“保存”按钮以提交更改
SharePoint Online:如何使用 SharePoint Designer 隐藏左侧导航?
您还可以从 SharePoint Designer 隐藏 SharePoint Online 中的快速启动。打开SharePoint设计器网站并取消选中设置下的“显示快速启动”并保存!
SharePoint Online:使用 PowerShell 禁用快速启动
以下是在 SharePoint Online 中隐藏左侧导航的方法:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Variable
$SiteURL="https://Crescent.sharepoint.com/sites/Marketing"
#Setup Credentials to connect
$Cred = Get-Credential
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
#Disable Quick Launch
$Ctx.Web.QuickLaunchEnabled = $False
$Ctx.Web.Update()
$Ctx.ExecuteQuery()
Write-host -f Green "Quick Launch Bar Disabled Successfully!"
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
使用 PnP PowerShell 隐藏快速启动:
要隐藏 SharePoint Online 中的左侧导航栏,请使用此 PnP PowerShell:
#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/sites/marketing"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the Web
$Web = Get-PnPWeb
#hide left navigation bar in sharepoint online
$web.QuickLaunchEnabled = $False
$web.Update()
Invoke-PnPQuery
如果快速启动菜单的方向也设置为水平(顶部导航菜单),则此脚本将起作用。您还可以使用 Set-PnPWeb cmdlet 禁用 SharePoint Online 网站上的导航:
Set-PnPWeb -QuickLaunchEnabled:$false
使用 CSS 隐藏 SharePoint Online 中的左侧导航
您可以部署实现 CSS 的 SPFx 扩展(或使用“现代脚本编辑器 Web 部件”并将其添加到页面)。要在现代页面上隐藏左侧导航的 CSS,请使用以下 CSS:
<style>
#spLeftNav {
display: none !important;
}
</style>
有关使用 CSS 删除左侧导航的方法的更多信息:使用 CSS 隐藏 SharePoint Online 快速启动
总之,在 SharePoint Online 中隐藏左侧导航栏是简化用户界面并使内容脱颖而出的有效方法。通过使用 PowerShell,您可以跨多个站点自动执行此过程,从而更轻松地管理您的 SharePoint 环境。通过执行本文中概述的步骤,您可以快速轻松地隐藏 SharePoint Online 中的左侧导航栏。


