当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 在 SharePoint Online 中创建网站页面库

作者:精品下载站 日期:2024-12-14 16:08:43 浏览:14 分类:玩电脑

在 SharePoint Online 中创建网站页面库


要求:在 SharePoint Online 中创建网站页面库。

网站页面库是一个独特的库,用于存储您网站的页面。您可以使用网站页面库创建和存储可用于共享信息并与团队协作的页面。如果网站页面库由于某种原因丢失/删除,SharePoint Online 网站将开始显示“404 NOT FOUND”错误!要在 SharePoint Online 中创建网站页面库,请执行以下步骤:

方法一:激活“网站页面”功能创建网站页面库

“站点页面”站点级功能将“站点页面”库引入站点。因此,请按照以下步骤操作并激活该功能以获取网站页面库。

  1. 导航到您的 SharePoint Online 网站。
  2. 单击“设置”>> 选择“站点设置”(https://YourDomain.sharepoint.com/sites/YourSite/_layouts/15/settings.aspx))
  3. 单击“网站操作”组下的“管理网站功能”。
  4. 找到“站点页面”功能,然后单击旁边的“激活”。如果已激活,请停用一次,然后再次激活。

    [玩转系统] 在 SharePoint Online 中创建网站页面库

  5. 这将带来丢失的“站点页面”库。您可以创建新的网站页面并将其设置为网站的主页。

网站页面库现在将显示在“网站内容”列表中。您可以使用此库来存储和组织您的网站页面。您还可以使用它来创建新页面、编辑现有页面以及根据需要删除页面。

选项 2:使用 PowerShell 在 SharePoint Online 中创建网站页面库

如果上述步骤对您不起作用,这里是用于在 SharePoint Online 网站中创建网站页面库的 PowerShell。此 PnP PowerShell 脚本创建站点页面库并向其中添加“站点页面”内容类型。


#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Purchase"

Try {
    #Connect to SharePoint Online site
    Connect-PnPOnline -Url $SiteURL -Interactive

    #Get the context
    $Ctx = Get-PnPContext

    #Check if the Site Pages Library Exists
    $SitePagesLibrary = Get-PnPList -Identity "Site Pages" 
    
    If($SitePagesLibrary -eq $Null)
    {
        #Create Site Pages Library in sharepoint online using powershell
        $ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
        $ListInfo.Title = "Site Pages"
        $ListInfo.Url = "SitePages"
        $ListInfo.TemplateType = 119 #Site Pages library template
        $List = $Ctx.Web.Lists.Add($ListInfo)
        $List.Update()
        Invoke-PnPQuery
        Write-host "Site Pages Library Created!" -f Green
    }
    Else
    {
        Write-Host -f Yellow "Site Pages Library already exist!"
    }

    #Add "Site Page" Content type to the "Site Pages" library
    $ContentType = Get-PnPContentType -Identity "Site Page"
    If($ContentType)
    {
        #Check if the Library has the content type already
        $SitePageContentType = Get-PnPContentType -List "Site Pages" -Identity "Site Page" -ErrorAction SilentlyContinue
        If(!$SitePageContentType)
        {
            #Add Content Type to Library
            Add-PnPContentTypeToList -List "Site Pages" -ContentType $ContentType
            Write-host "Site Page content type added to the Library" -f Green
        }
        Else
        {
            Write-host "Site Page content type already exists in the Library!" -f yellow
        }
    }
    Else
    {
        Write-host -f Yellow "Could Not Find the 'Site Page' Content Type! Activate the Site Pages Feature" -f Yellow
    }
}
Catch {
    Write-host -f Red "Error:" $_.Exception.Message
}

网站页面库准备就绪后,您可以创建新的网站页面,向其中添加内容并将其设置为主页。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯