Modern SharePoint Online Programming - Chapter Two

Let's explore a simple way to create a modern communication site and register it as a hub. Once registered let's add a logo image along with a footer. Let's use a comm site as it has footer enabled. We'll customize it further using the below PnP & SP Online PowerShell program rather than using the Modern Team site for this approach.
 
Open the SharePoint Online Management Shell.
 
Run the below commands after fine tuning the details for your usage.
  1. $Tenantadminurl = "https://<TenantName>-admin.sharepoint.com/"  
  2. Connect-PnPOnline $Tenantadminurl -useweblogin  
  3. # Create the new "modern" communication site with SiteDesign Topic/Showcase/Blank  
  4. $communicationSiteUrl = New-PnPSite -Type CommunicationSite -Title "TestHubE" -Url "https://bunnomatic1.sharepoint.com/sites/TestHubE" -Description "TestHubE" -Classification "HubE" -SiteDesign Blank  
  5. # Connect to the modern site using PnP PowerShell SP cmdlets  
  6. # Since we are connecting now to SP side, credentials will be asked  
  7. Connect-PnPOnline $communicationSiteUrl -useweblogin  
  8. # Now we have access on the SharePoint site for any operations  
  9. $context = Get-PnPContext  
  10. $web = Get-PnPWeb  
  11. #$context.Load($web, $web.Title)  
  12. #Execute-PnPQuery  
  13. $web.Title  
  14. Connect-pnponline -url $communicationSiteUrl -useweblogin  
  15. Apply-PnPProvisioningTemplate -Path D:\SiteFooter1.xml  
  16. #Using SPOService Connection  
  17. $cred = [System.Net.CredentialCache]::DefaultCredentials  
  18. [System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred  
  19. #If you want to turn it as a Hub site  
  20. Connect-SPOService -Url $Tenantadminurl  
  21. #Register-PnPHubSite -Site $communicationSiteUrl  
  22. Register-SPOHubSite $communicationSiteUrl -Principals $null  
  23. $Hubsite=$communicationSiteUrl  
  24. Set-SPOHubSite $Hubsite `  
  25. -Title "Hub E" `  
  26. -LogoUrl https://<TenantName>.sharepoint.com/:i:/s/Tenant/EZKYy9jsoyNOiD0zb4o3OI4BFnSpWZKkJ9rbE0o9806KRw?e=vYk6Si `  
  27. -Description "Hub for the 'E' division”  
  28. #Please provide the Logo url exactly the location where your Logo is available and don't ommit that ` symbol.  
  29. Get-SPOHubSite -Identity $Hubsite  
The above code also has SiteFooter.xml which has the below code in it and can be tuned/added/edited with more changes as per your footer customizations.
  1. <?xml version="1.0"?>  
  2. <pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2019/03/ProvisioningSchema">  
  3. <pnp:Preferences Generator="OfficeDevPnP.Core, Version=3.10.1906.0, Culture=neutral, PublicKeyToken=null" />  
  4. <pnp:Templates ID="CONTAINER-TEMPLATE-349B964A1A644BA3A310BFA16668495E">  
  5. <pnp:ProvisioningTemplate ID="TEMPLATE-349B964A1A644BA3A310BFA16668495E" Version="1" BaseSiteTemplate="SITEPAGEPUBLISHING#0" Scope="RootSite">  
  6. <pnp:Footer Enabled="true" RemoveExistingNodes="true">  
  7. <pnp:FooterLinks>  
  8. <pnp:FooterLink DisplayName="Contact Us" Url="mailto:[email protected]" />  
  9.   
  10. <pnp:FooterLink DisplayName="IT Support" Url="http://ClientName.zendesk.com" />  
  11. <pnp:FooterLink DisplayName="Help" Url="https://<TenantName>.sharepoint.com/sites/Client/SitePages/Client-Hubs-Help-Page.aspx" />  
  12.   
  13. </pnp:FooterLinks>  
  14. </pnp:Footer>  
  15. </pnp:ProvisioningTemplate>  
  16. </pnp:Templates>  
  17. </pnp:Provisioning>  
The above site footer code has 3 footer links and needs to be added in the reverse order to show its effect from left to right on your site collection page.