How to Host Static Website on Sharepoint Online

How to Host Static Website on SharePoint Online (HTML-ASPX)

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!

What is a static website?

There are two basic types of websites:

  1. Static
  2. 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
    sharepoint option in admin centers

    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
    go to the classic settings 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:

    Allow users to run custom script

    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:

    warning about changing the file name extension

    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:

    static website files for space science free website template

    With that done, you can now view your static site.

    For example, when I opened the index aspx file, this is what I saw:

    index html file of the sample static website

    Nice! 😎

    Hosting Websites on SharePoint

    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.

    About Ryan Clark

    As the Modern Workplace Architect at Mr. SharePoint, I help companies of all sizes better leverage Modern Workplace and Digital Process Automation investments. I am also a Microsoft Most Valuable Professional (MVP) for SharePoint and Microsoft 365.

    Subscribe
    Notify of
    guest
    2 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments

    Erik Palencik
    Erik Palencik
    7 months ago

    In option 4 the file is downloaded not previewed…

    David
    David
    7 months ago

    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 »

    2
    0
    Would love your thoughts, please comment.x
    ()
    x
    Scroll to Top