Setting up my Markdown blogging site with Razor SSG
I spent hours trying to Get the Index page to redirect to the blog​
How hard can it be?
Turns out it is hard. And it was because I misunderstood how sites are built when hosted at "username".github.io
.
When I added a onGet()
function to the index page, it was to redirect to the Blog.cshtml page through a pattern matching string with LocalRedirectResult("/blog")
method.
This yielded the result I wanted in my development environment. But When hosted on Github Pages, I noticed that the root page had changed.
benjinotn.github.io/razor-blog
What to do now! The onGet()
command doesn't trigger because razor-blog is in the way! (I don't know how each to describe this).
## Plan B: Delete Index and replace it with Blog
I thought changing Blog.cshtml to include @model('/')
would fix it, now the default page opens the blog! But spoilers! Another problem occurs in production!
When changing the navbar link to this new '/' location, the root isn't referenced correctly, resulting in the dreaded 404.
With a hearthy sigh, I realised I had to do what no one wants to do...​
## Plan C: Spend Money
I spent $9 on a domain name. Feeling fairly sorry for myself at this stage. I added it to the settings page
tab on github and added a CNAME configuration to the DNS so it functioned as an alias. I'm just very lucky that the build.yml script that was included in the razor SSG template had conditions for building with custom domains.
No weird razor-blog
extension, no failed navbar references, The blog is default! And it is hosted Here!
My next plans are to add commenting, user functionality for some discussion. But judging by the speed of this features implementation, it won't be here any time soon!