👻Static Host in Github

Host Static Application in Github

Cover

Blazor Static Web Application

Cover

Host in GitHub

Cover

Host in Netlify

Steps to Create Static Web Site and host in Github

  1. Create a Static Web Application using Blazor or any Just a HTML file

  2. Create a Github Repository.

  3. Clone the Github Repository

  4. Publish the Static Web Application

  5. Copy the "Publish" files

  6. Create the ".nojekyll", file.

  7. Check in the code

  8. Configure the Github Web Page

  9. Test the same in web browser

  10. Base URL Settings


Step 1: Blazor WebAssembly

Select the Blazor WebAssembly Standalon Application and set the Framework as .NET 8.0.

Step 2: Solution Listing

Step 3: Publish the "Web.Profile" Application

Settings Changes

Files stored

  1. The pusblish file located in the "C:\Github\Web.Profile\Publish\wwwroot".

  2. This published files to be checked in to the Github Location, and remmeber that the root folder should have "index.html".

  3. Hence we should replace this wwwroot and cut and paste in the root GitHub repository directly.

Step 4: Github Repository

Step 5: Clone and Checkin the Code Repository

  1. Now Create the file called ".nojekyll" file.

  2. Checkin the code.

Step 6: Github Page Settings

Important Notes

// Some code

 <script type="text/javascript">
     function SetBaseScript() {
         console.log(window.location.hostname);
         if (window.location.hostname == "localhost") {
             console.log ("Local Host True");
             document.write("<base href='/' />");
         } else {
             document.write("<base href='/Web.Profile/' />");
         }
     }
     SetBaseScript();
 </script>
 

Last updated

Was this helpful?