Hexo+ServerlessFramework怎樣搭建你的個(gè)人博客

Hexo + Serverless Framework怎樣搭建你的個(gè)人博客,相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

創(chuàng)新互聯(lián)公司是一家成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì),提供網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),網(wǎng)站制作,建網(wǎng)站,按需策劃,網(wǎng)站開發(fā)公司,2013年至今是互聯(lián)行業(yè)建設(shè)者,服務(wù)者。以提升客戶品牌價(jià)值為核心業(yè)務(wù),全程參與項(xiàng)目的網(wǎng)站策劃設(shè)計(jì)制作,前端開發(fā),后臺(tái)程序制作以及后期項(xiàng)目運(yùn)營并提出專業(yè)建議和思路。

很多人都想擁有自己的個(gè)人博客,還得看起來漂亮、酷酷的。下面里介紹兩款好用的神器搭建個(gè)人博客。

工具介紹

  • Serverless Framework:Serverless Framework 是業(yè)界非常受歡迎的無服務(wù)器應(yīng)用框架,開發(fā)者無需關(guān)心底層資源即可部署完整可用的 Serverless 應(yīng)用架構(gòu)。

  • Hexo:Hexo 是一個(gè)快速、簡潔且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在幾秒內(nèi),即可利用靚麗的主題生成靜態(tài)網(wǎng)頁。

使用 Serverless Framework 部署一個(gè) Hexo 網(wǎng)站只需三步::安裝與初始化 → 配置 yml 文件 → 部署

安裝與初始化

簡單三步,即可通過 Serverless Website 組件快速構(gòu)建一個(gè) Serverless Hexo 站點(diǎn)。

首先確保系統(tǒng)包含以下環(huán)境:

  • Node.js (Node.js 版本需不低于 8.6,建議使用 Node.js 10.0 及以上版本)

  • Git

如未安裝上述應(yīng)用程序,可以參考安裝說明。

1. 安裝 Serverless Framework

$ npm install -g serverless

2. 安裝 Hexo

$ npm install -g hexo-cli

3. 初始化項(xiàng)目

$ hexo init hexo   # 生成hexo目錄
$ cd hexo
$ npm install

初始化完成后,hexo 文件夾的目錄如下:

.
├── _config.yml
├── package.json
├── scaffolds
├── source
|   ├── _drafts
|   └── _posts
└── themes

4. 生成本地博客頁面

hexo g   # generate

可以通過 hexo g 命令生成靜態(tài)頁面,如果希望在本地查看效果,也可以運(yùn)行下列命令,通過瀏覽器訪問 http://localhost:4000 查看頁面效果。

hexo s   # server

配置 yml 文件

項(xiàng)目目錄下,創(chuàng)建 serverless.yml 文件

cd.> serverless.yml

將以下內(nèi)容寫入上述的 yml 文件里:

# serverless.yml

myWebsite:
  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

配置完成后,文件目錄如下:

.
├── .serverless
├── hexo
|   ├── public
|   ├── ...
|   ├── _config.yml
|   ├── ...
|   └── source
└── serverless.yml

部署

通過 sls 命令進(jìn)行部署,并可以添加 --debug 參數(shù)查看部署過程中的信息

如您的賬號(hào)未登陸或注冊(cè)騰訊云,您可以直接通過微信掃描命令行中的二維碼進(jìn)行授權(quán)登陸和注冊(cè)。

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 wechat
Wait 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

訪問命令行輸出的 website url,即可查看屬于自己的 Serverless Hexo 站點(diǎn)。

如果需要更新 hexo 站點(diǎn)中的文章,只需要在本地重新運(yùn)行 hexo g 更新本地頁面,再運(yùn)行 sls 就可以直接更新到 Hexo 網(wǎng)站啦

看完上述內(nèi)容,你們掌握Hexo + Serverless Framework怎樣搭建你的個(gè)人博客的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

文章標(biāo)題:Hexo+ServerlessFramework怎樣搭建你的個(gè)人博客
文章鏈接:http://muchs.cn/article34/iiogse.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、響應(yīng)式網(wǎng)站域名注冊(cè)、網(wǎng)站內(nèi)鏈、品牌網(wǎng)站設(shè)計(jì)、外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管