Forum Discussion
Lee-Martin
Jan 10, 2023Brass Contributor
Add html code to Modern Page
I've some html code (with css) that I want to add to the page I've tried uploading it to Site Assets as an aspx file, but it won't let me embed it. I just need to do this as a quick one off a...
SvenSieverding
Jan 10, 2023Bronze Contributor
Lee-Martin
"Disable Custom Scripting" is enabled per default on new sites because of security concerns. So custom ".aspx" files are always downloaded and not displayed.
To disable "Disable Custom Scripting" do the following:
1) Be a SharePoint Administrator (SiteCollection Admin is not sufficient)
2) Either connect with the SharePoint Management Shell to the SharePoint admin site (https://<tenant>-admin.sharepoint.com) and execute
Set-SPOSite <SiteURL> -DenyAddAndCustomizePages 0
3) Or connect with PNP Powershell to the SharePoint admin site (https://<tenant>-admin.sharepoint.com) and execute
Set-PnPSite -Identity <SiteURL> -NoScriptSite $false
(https://learn.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script)
Best Regards,
Sven
- Adnan_AminJan 10, 2023MVPAgree with Sven. you can enable custom scripting on the site or you can use spfx web part for the required output.