👻Static Host in Github
Host Static Application in Github

Blazor Static Web Application

Host in GitHub
Host in Netlify
Steps to Create Static Web Site and host in Github
Create a Static Web Application using Blazor or any Just a HTML file
Create a Github Repository.
Clone the Github Repository
Publish the Static Web Application
Copy the "Publish" files
Create the ".nojekyll", file.
Check in the code
Configure the Github Web Page
Test the same in web browser
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
Web.Profile
" Application
Settings Changes
Files stored
The pusblish file located in the "
C:\Github\Web.Profile\Publish\wwwroot
".This published files to be checked in to the Github Location, and remmeber that the root folder should have "
index.html
".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

Step 6: Github Page Settings

Step 7: Check the Link
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>
When we host and run in the github, the base url might have been changed for examlple
https://{weburl.github.com/{static-host}/.
This has to be changed. The above code will identify and replace based on our need.
Eg. In the above code, if it is running on the local host, the base href will be set to href="/"
, else href="/Web.Profile/"
which is the repository of Github.
Last updated
Was this helpful?