Welcome to my blog and this is my first post!
Nowadays you have a lot of options (List of Top Open-Source Static Site Generators) and tools to start your own blog, but I have already personal web site and main requirement was to stick to current technology stack and tools as much as possible.
I did research and decided to use Hexo as blog engine. Next step was an integration to ASP.NET Core application and this experience I want to share with you.
I am going to share entire process step by step from zero to complete solution. Feel free to skip steps which you already did.
I hope that you are familiar with ASP.NET Core and get SDK installed, otherwise check dot.net resource.
But create a new web application is very easy:
Once you have done you can navigate to http://localhost:5000 and check that site is running. If you see following picture you are good.
Installation and configuraion is even easy then previous step. There are only two prerequisites:
I recommend to visit official guide in case of issues. Once you have installed and configured them we need only one quick step:
npm install -g hexo-cli
and we have everything to start blogging.
Create a new directory (e.g. Blog) in your ASP.NET Core application and initialize Hexo in this directory:
Go to newly created directory:
And initialize Hexo under this directory:
After this step you will see next structure in your directory:
Now you are ready to start blogging with Hexo, but we need to integrate two applications in one.
Open _config.yml file (more info) and find public_dir setting, you need point to “../wwwroot/blog“ (pay attention to path segment separator, it allows to build right path across POSIX and Windows platforms).
Also update url setting:
After that you can generate static content:
Next step is to configure ASP.NET Core web application.
To configure web application you need some text editor, I prefer Visual Studio Code.
Open project.json file and check that there is package Microsoft.AspNetCore.StaticFiles (if you do not have you can easily install from Nuget)
Then open Startup.cs file and find Configure method, in this section we need to add a few lines of code:
More details about UseFileServer you can find docs.microsoft.com, shortly UseFileServer combines the functionality of UseStaticFiles, UseDefaultFiles, and UseDirectoryBrowser.
Finally, you can run ASP.NET Core application with new code and go to the http://localhost:5000/blog and you will see that your new blog is here:
That is all what I want to share in my “Hello World” post. New and more technical posts are upcoming.