Last Updated on April 4, 2025
Can you host a static website on SharePoint?
In this guide, we’ll talk about whether or not it’s possible to host static websites on SharePoint Online, and if so, how to go over it.
Let’s get started!
Table of Contents:
What is a static website?
There are two basic types of websites:
- Static
- Dynamic
Static sites basically consist of a series of HTML files that represent the physical pages of the website.
The reason why they’re called “static” is that they give the same fixed content to every visitor, unlike dynamic sites.
You can actually use SharePoint to host the site files — it was easy with the classic SharePoint (still doable with modern).
Unfortunately, you can only do this for static HTML pages and not for dynamic pages that change.
Sign up for exclusive updates, tips, and strategies
How to Host a Static Website
The feature that can host sites is disabled by default in the modern experience, which is why you must activate it first.
Let’s take this step by step:
Step 1: Allow custom scripts on the tenant
For this, you have to access the SharePoint admin center.
If you don’t know how, follow these quick steps:
- Click the app launcher > admin on any Microsoft 365 page
- Show all admin center options in the left pane
- Select the SharePoint option

You’re now in the SharePoint admin center.
You will have to navigate now to the classic settings page:
- Go to settings from the left pane
- Click the classic settings page link below the page

All you have to do here is to scroll down the bottom until you see the options for the custom script feature.
Enable the options to allow users to run custom scripts on:
- Personal sites
- Self-service created sites

Just click the ok button at the bottom of the page after that. 🙂
By the way, depending on how big the tenant is, the changes might take up to 24 hours before they’re applied to all the sites.
Step 2: Allow custom scripts on the site collection
Don’t worry, this one is easier.
Simply copy the script and edit the site URL parameter:
# Define the URL of your SharePoint Online site collection
$siteUrl = "https://yourtenant.sharepoint.com/sites/yoursite"
# Establish a connection to your SharePoint Online site
Connect-PnPOnline -Url $siteUrl -Interactive
# Fetch the site collection details
$siteCollection = Get-PnPSite
# Enable custom scripts on the SharePoint Online site collection
Set-PnPSite -Identity $siteCollection.URL -NoScriptSite $false
That’s it!
Easy, right? 🙂
Step 3: Change format to ASPX
For this next step, all you need to do is change the .html extension to .aspx.
You might get a warning like the following:

But ignore it since this extension is usable when in SharePoint.
Do that for all the .html files of the static website.
Note that for this guide, I downloaded a free space science template from this website.
Step 4: Upload the website files
For this next part, all you have to do is upload all the website files into the same document library.
My suggestion here is to create another document library rather than copying all those files to the document library.
It should look like this:

With that done, you can now view your static site.
For example, when I opened the index aspx file, this is what I saw:

Nice! 😎
As you can see, hosting a static website on SharePoint Online isn’t really that complicated.
All you have to do is allow custom scripts, change the file extension name, and upload them on a document library.
Got any questions about hosting static websites on SharePoint Online? Feel free to leave a comment.
For business inquiries and concerns, kindly reach out using the contact form here and I’ll get back to you asap.
In option 4 the file is downloaded not previewed…
Thank you Ryan for the awesome tutorial. I used to have Custom Scripts enabled on my SharePoint website, but for some reason it got disabled in the meantime. However, the ASPX pages that I had uploaded while “Custom Scripts” was enabled still work. Only if I change or even only rename an ASPX file or upload a new ASPX file, then these are not shown as websites anymore but downloaded instead by the browser. Some very simple ASPX files, while they are opened by the browser, are displayed empty. Is that to be expected? In other words, will this problem… Read more »