Hexo+ServerlessFramework怎樣搭建你的個人博客

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

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

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

工具介紹

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

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

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

安裝與初始化

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

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

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

  • Git

如未安裝上述應用程序,可以參考安裝說明。

1. 安裝 Serverless Framework

$ npm install -g serverless

2. 安裝 Hexo

$ npm install -g hexo-cli

3. 初始化項目

$ 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)頁面,如果希望在本地查看效果,也可以運行下列命令,通過瀏覽器訪問 http://localhost:4000 查看頁面效果。

hexo s   # server

配置 yml 文件

項目目錄下,創(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 命令進行部署,并可以添加 --debug 參數(shù)查看部署過程中的信息

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

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 站點。

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

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

文章標題:Hexo+ServerlessFramework怎樣搭建你的個人博客
文章鏈接:http://bm7419.com/article34/iiogse.html

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

廣告

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

綿陽服務器托管