So, you want to maintain a serverless blog? Well, I also have put together this blog just using the followings
- Route 53
Before get started in details step-by-step, please allow to write few words on expected outcome: after completeing all the steps you should be able to have your serverless blog ready for your visitors!
npm install hexo-cli -g
Let’s create a draft blog using the following command,
hexo new draft "My First Blog Post"
which should create a markdown file in source/_draft.
When you feel that you are doing with drafting the post and ready to publish, do so using:
hexo publish draft "My First Blog Post"
At this point, you can try to run the server without draft mode and you should still see the post on localhost:4000
Let’s create a bucket from where visitor will be served the blog. To do so:
- Login to your AWS console
- Select S3 from Services
- Click Create bucket
- Type Bucket name, choose a Region and then click Next
- Click Next on Configure options window
- In the Set permissions window, uncheck Block all public access and click Next
- And finally click Create Bucket in Review window
After bucket is created, let’s enable Static website hosting, to do so:
- Select your bucket from Buckets
- Click Properties tab
- Select Static website hosting
- Select Use this bucket to host a website radio button
- And then click Save
One last thing to the bucket, update bucket policy:
- Select Permissions tab
- Select Bucket Policy
- Copy following policy and replace your-bucket-name with a valid bucket name
- And finally click Save to make your bucket ready!
Before try to generate static files and upload to s3, let’s install npm package
npm install hexo-deployer-aws-s3 --save
and then modify
Let’s generate static file which we will be putting on s3 bucket so that our vistor can read blog post.
Assuming you have AWS credentials in
Now, let’s find the endpoint of the site hosted on s3:
- Go to bucket’s
Static website hosting
At this point, your site should be accessible using the endpoint.
One last thing to host your site on your own doamin.
- Add an
A-recordaliased to the endpoint retrieved earlier.
Route 53as DNS service provider, you can use your existing name server as well.
That’s it. Happy