Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build your personal blog with Hexo + Serverless Framework

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Hexo + Serverless Framework how to build your personal blog, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

A lot of people want to have their own personal blog, and they have to look beautiful and cool. Here are two useful artifacts to build a personal blog.

Tool introduction

Serverless Framework:Serverless Framework is a very popular serverless application framework in the industry, and developers can deploy a fully available Serverless application architecture without paying attention to the underlying resources.

Hexo:Hexo is a fast, concise and efficient blogging framework. Hexo uses Markdown (or any other rendering engine) to parse articles and generate static web pages with beautiful themes in a matter of seconds.

It takes only three steps to deploy a Hexo website using Serverless Framework: install and initialize the → configuration yml file → deployment

Installation and initialization

In three simple steps, you can quickly build a Serverless Hexo site through Serverless Website components.

First, make sure that the system contains the following environments:

Node.js (Node.js version should be no less than 8.6, Node.js 10.0 or above is recommended)

Git

If the above applications are not installed, you can refer to the installation instructions.

1. Install Serverless Framework

$npm install-g serverless

two。 Install Hexo

$npm install-g hexo-cli

3. Initialize the project

$hexo init hexo # generate the hexo directory $cd hexo$ npm install

After initialization, the directory of the hexo folder is as follows:

.├── _ config.yml ├── package.json ├── scaffolds ├── source | ├── _ drafts | └── _ posts └── themes

4. Generate a local blog page

Hexo g # generate

You can generate a static page through the hexo g command, or if you want to see the effect locally, you can also run the following command to visit http://localhost:4000 through the browser to see the page effect.

Hexo s # server configuration yml file

Under the project directory, create a serverless.yml file

Cd. > serverless.yml

Write the following to the yml file above:

# serverless.ymlmyWebsite: component:'@ serverless/tencent-website' inputs: code: src:. / localhexo/public # Upload static files generated by HEXO index: index.html error: index.html region: ap-guangzhou bucketName: my-bucket-hexo

After the configuration is complete, the file directory is as follows:

.├── .serverless ├── hexo | ├── public | ├──. | ├── _ config.yml | ├──. | └── source └── serverless.yml deployment

Deploy through the sls command, and you can add the-- debug parameter to view the information in the deployment process

If your account is not logged in or registered with Tencent Cloud, you can log in and register directly through the QR code in the command line scanned by Wechat.

PS serverless-debug DEBUG ─ Resolving the template's static variables. DEBUG ─ Collecting components from the template. DEBUG ─ Downloading any NPM components found in the template. DEBUG ─ Analyzing the template's components dependencies. DEBUG ─ Creating the template's components graph. DEBUG ─ Syncing template state. DEBUG ─ Executing the template's components graph. DEBUG ─ Starting Website Component.Please scan QR code login from wechatWait login...Login successful for TencentCloud DEBUG ─ Preparing website Tencent COS bucket my-bucket-1250000000. DEBUG ─ Deploying "my-bucket-1250000000" bucket in the "ap-guangzhou" region. DEBUG ─ "my-bucket-1250000000" bucket was successfully deployed to the "ap-guangzhou" region. DEBUG ─ Setting ACL for "my-bucket-1250000000" bucket in the "ap-guangzhou" region. DEBUG ─ Ensuring no CORS are set for "my-bucket-1250000000" bucket in the "ap-guangzhou" region. DEBUG ─ Ensuring no Tags are set for "my-bucket-1250000000" bucket in the "ap-guangzhou" region. DEBUG ─ Configuring bucket my-bucket-1250000000 for website hosting. DEBUG ─ Uploading website files from D:\ hexotina\ localhexo\ public to bucket my-bucket-1250000000. DEBUG ─ Starting upload to bucket my-bucket-1250000000 in region ap-guangzhou DEBUG ─ Uploading directory D:\ hexotina\ localhexo\ public to bucket my-bucket-1250000000 DEBUG ─ Website deployed successfully to URL: https://my-bucket-1250000000.cos-website.ap-guangzhou.myqcloud.com. MyWebsite: url: https://my-bucket-1250000000.cos-website.ap-guangzhou.myqcloud.com env: 13s »myWebsite »done

Visit the website url output from the command line to view your own Serverless Hexo site.

If you need to update the articles in the hexo site, just rerun hexo g locally to update the local page, and then run sls to update directly to the Hexo website.

After reading the above, have you mastered how Hexo + Serverless Framework can build your personal blog? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report