最新博客链接

Github链接

查看此文档前应先了解,vuepress基本操作

参考官方文档进行配置:

vuepress-theme-reco

VuePress

SamKirkland / FTP-Deploy-Action

最终效果

最终效果链接

思路

下载vuepress-theme-reco官方的主题模板(脚手架),再根据自己的需要进行相应的修改,再根据自己的服务器配置Github Actions文件,最后上传到Github,触发Github Actions自动构建部署到第三方服务器。以后就只需提交markdown文件到Github,Github Actions便可自动部署到第三方服务器

用到的东西

  • vuepress-theme-reco

  • VuePress

  • Github Actions

  • SamKirkland / FTP-Deploy-Action

相关

  • vuepress-theme-reco:

    一款简洁而优雅的 vuepress 博客 & 文档 主题。

  • Github Actions:

    GitHub 操作 帮助您在您存储代码的同一位置自动执行软件开发工作流程,并协作处理拉取请求和议题。 您可以写入个别任务,称为操作,并结合它们创建一个自定义的工作流程。 工作流程是您可以在仓库中创建的自定义自动化流程,用于在 GitHub 上构建、测试、封装、发行或部署任何代码项目。

    通过 GitHub 操作 可直接在仓库中构建端到端持续集成 (CI) 和持续部署 (CD) 功能。

  • SamKirkland / FTP-Deploy-Action:

    Automate deploying websites and more with this GitHub action

    通过GitHub action自动部署网页等操作

博客主题配置

快速开始

使用模板

  1. # 初始化
  2. sudo yarn global add @vuepress-reco/theme-cli
  3. theme-cli init my-blog
  4. # 安装
  5. cd my-blog
  6. sudo yarn install

更改最新依赖

  1. // package.json
  2. {
  3. "scripts": {
  4. "dev": "vuepress dev docs",
  5. "build": "vuepress build docs"
  6. },
  7. "dependencies": {
  8. "vuepress": "^1.4.0",
  9. "vuepress-theme-reco": "^1.3.2",
  10. "vuepress-plugin-flowchart": "^1.4.3",
  11. "@vuepress-reco/vuepress-plugin-bgm-player": "^1.1.2",
  12. "@vuepress/plugin-nprogress": "^1.4.0",
  13. "vuepress-plugin-reading-progress": "^1.0.8"
  14. }
  15. }

然后,安装依赖

  1. sudo yarn

目录结构

  1. .
  2. ├── .git-ftp-include // 用于最后指定需要部署的文件或文件夹
  3. ├── .gitattributes // 用于统一文件内编码的换行符
  4. ├── .github
  5. └── workflows
  6. └── nodejs.yml // Github Actions的配置文件
  7. ├── .gitignore // 忽略上传到Github的文件或目录
  8. ├── LICENSE // 许可证文件
  9. ├── README.md // Github项目展示文件
  10. ├── docs // VuePress项目根目录
  11. ├── .vuepress // 存放配置文件的文件夹
  12. ├── config.js // 整个工程的配置文件
  13. ├── dist // 最后生成的文件目录
  14. ├── public // 媒体文件夹(主要是图片)
  15. └── styles // 网页样式文件夹(里面空的,没有用)
  16. ├── README.md // 网页首页文件
  17. └── views // 存放markdown文件的文件夹(可以不要直接把markdown文件放在docs里面)
  18. └── frontEnd // 分类目录(也可以不要分类目录直接放在views里面)
  19. ├── package.json // 指定依赖,项目脚本,Node.js项目描述文件
  20. ├── yarn-error.log // 记录构建失败的日志文件
  21. └── yarn.lock // 变更依赖时自动生成和更新

添加博客配置

然后根据需要更改一些内容和设置,参考官方的文档,可自行取舍相应内容

vuepress-theme-reco

VuePress

  1. // docs/.vuepress/config.js
  2. module.exports = {
  3. // host: '0.0.0.0', // 生成网页地址(本地调试使用)
  4. // port: '22335', // 生成网页端口(本地调试使用)
  5. title: "Tsanfer's Blog", // 显示在左上角的网页名称以及首页在浏览器标签显示的title名称
  6. description: '现居住于猎户臂上的一个碳基生命', // meta 中的描述文字,用于SEO
  7. head: [
  8. ['link', { rel: 'icon', href: '/favicon.svg' }], //浏览器的标签栏的网页图标,基地址/docs/.vuepress/public
  9. ['meta', { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no' }], //在移动端,搜索框在获得焦点时会放大
  10. ],
  11. theme: 'reco', //选择主题‘reco’
  12. themeConfig: {
  13. type: 'blog', //选择类型博客
  14. blogConfig: {
  15. category: {
  16. location: 2, // 在导航栏菜单中所占的位置,默认2
  17. text: '分类' // 默认 “分类”
  18. },
  19. tag: {
  20. location: 3, // 在导航栏菜单中所占的位置,默认3
  21. text: '标签' // 默认 “标签”
  22. },
  23. },
  24. nav: [ //导航栏设置
  25. { text: '主页', link: '/', icon: 'reco-home' },
  26. { text: '时间线', link: '/timeline/', icon: 'reco-date' },
  27. { text: '联系',
  28. icon: 'reco-message',
  29. items: [
  30. { text: 'GitHub', link: 'https://github.com/Tsanfer', icon: 'reco-github' },
  31. { text: 'CSDN', link: 'https://blog.csdn.net/qq_27961843/', icon: 'reco-csdn' },
  32. { text: 'BiliBili', link: 'https://space.bilibili.com/12167681', icon: 'reco-bilibili' },
  33. { text: 'QQ', link: 'tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1124851454', icon: 'reco-qq' },
  34. { text: 'twitter', link: 'https://twitter.com/a1124851454', icon: 'reco-twitter' },
  35. { text: 'Gmail', link: 'mailto:a1124851454@gmail.com', icon: 'reco-mail' },
  36. ]
  37. }
  38. ],
  39. sidebar: 'auto', //在所有页面中启用自动生成侧栏
  40. record: '蜀ICP备20005033号-1',
  41. startYear: '2020', // 项目开始时间,只填写年份
  42. lastUpdated: '最后更新时间', // string | boolean
  43. author: 'Tsanfer',
  44. authorAvatar: '/avatar.svg', //作者头像
  45. mode: 'light', //默认显示白天模式
  46. // 评论设置
  47. valineConfig: {
  48. appId: process.env.LEANCLOUD_APP_ID,
  49. appKey: process.env.LEANCLOUD_APP_KEY,
  50. }
  51. },
  52. markdown: {
  53. lineNumbers: true //代码显示行号
  54. },
  55. // 搜索设置
  56. search: true,
  57. searchMaxSuggestions: 10,
  58. // 插件
  59. plugins: [
  60. ['flowchart'], // 支持流程图
  61. [
  62. '@vuepress-reco/vuepress-plugin-bgm-player', // BGM播放器
  63. {
  64. audios: [
  65. {name: 'Faster Than Light',artist: 'Andreas Waldetoft / Mia Stegmar',url: 'https://cdn-image.tsanfer.xyz/music/Andreas%20Waldetoft%2CMia%20Stegmar%20-%20Faster%20Than%20Light.mp3',cover: 'https://p1.music.126.net/Gxv6d9W4Yd9q9WNHPpi8rw==/1379887104073348.jpg'},
  66. {name: 'Dawn',artist: 'DDRKirby(ISQ)',url: 'https://cdn-image.tsanfer.xyz/music/Dawn%20-%20DDRKirby%28ISQ%29.mp3',cover: 'https://p2.music.126.net/IPnqMCk8YaN9inwYV2bdgQ==/18774161044446693.jpg'},
  67. {name: 'TRON Legacy (End Titles)',artist: 'Daft Punk',url: 'https://cdn-image.tsanfer.xyz/music/Daft%20Punk%20-%20TRON%20Legacy%20%28End%20Titles%29.mp3',cover: 'https://p2.music.126.net/qOOTIykbSLw9RHB0vI83GA==/737772302281958.jpg'},
  68. {name: 'Broken Boy',artist: 'Tonspender',url: 'https://cdn-image.tsanfer.xyz/music/Tonspender%20-%20Broken%20Boy.flac',cover: 'https://p2.music.126.net/4TnTRyHqa3-D2H1UnOa00w==/109951163666994621.jpg'},
  69. {name: 'Life Of Sin Pt. 4',artist: 'MitiS',url: 'https://cdn-image.tsanfer.xyz/music/MitiS%20-%20Life%20Of%20Sin%20Pt.%204.mp3',cover: 'https://p2.music.126.net/LmjTrSwvSLSNBsfFsQFO6g==/2533274793491743.jpg'},
  70. {name: 'Sea Of Voices (RAC Mix)',artist: 'Porter Robinson',url: 'https://cdn-image.tsanfer.xyz/music/Porter%20Robinson%20-%20Sea%20Of%20Voices%20%28RAC%20Mix%29.mp3',cover: 'https://p1.music.126.net/zjQROkEUokU7iS5eUvnVZQ==/3264450027161111.jpg'},
  71. {name: 'New Lipstick',artist: 'The Kissaway Trail',url: 'https://cdn-image.tsanfer.xyz/music/The%20Kissaway%20Trail%20-%20New%20Lipstick.flac',cover: 'https://p2.music.126.net/VjN74c1hoYgPCEZ9DngeQw==/109951163772624643.jpg'},
  72. ],
  73. },
  74. ],
  75. ['vuepress-plugin-smooth-scroll'], // 平滑滚动
  76. ['@vuepress/nprogress'], // 加载进度条
  77. ['reading-progress'] // 阅读进度条
  78. ]
  79. }

Github Actions配置

修改Github Actions配置文件

在Github网页上添加Github Actions配置文件,参考官方的文档,可自行取舍相应内容,其中需要保密的部分需要添加Github Secrets环境变量

SamKirkland / FTP-Deploy-Action

  1. # .github/workflows/nodejs.yml
  2. on: push # 触发此文件运行的条件
  3. name: Github Actions # 此工作流程(workflow)的名字
  4. jobs:
  5. FTP-Deploy-Action:
  6. name: FTP-Deploy-Action # 此任务(job)的名字
  7. runs-on: ubuntu-latest # 运行环境
  8. steps:
  9. - uses: actions/checkout@master # 切换分支到master
  10. with:
  11. fetch-depth: 2
  12. - name: Use Node.js 12.x
  13. uses: actions/setup-node@v1
  14. with:
  15. node-version: '12.x'
  16. - name: Build Project # 此步骤(step)的名字
  17. run: yarn && yarn build # 下载依赖和构建项目
  18. env:
  19. LEANCLOUD_APP_ID: ${{ secrets.LEANCLOUD_APP_ID }} # 评论系统的ID
  20. LEANCLOUD_APP_KEY: ${{ secrets.LEANCLOUD_APP_KEY }} # 评论系统的KEY
  21. - name: List output files
  22. run: ls -a docs/.vuepress/dist # 显示生成的目录文件
  23. - name: FTP-Deploy-Action
  24. uses: SamKirkland/FTP-Deploy-Action@3.0.0
  25. with:
  26. ftp-server: sftp://${{ secrets.FTP_IP }} # 服务器地址和端口(可以填域名,不过我服务器做了全站加速会导向加速结点的IP,所以只能用服务器的IP)
  27. ftp-username: ${{ secrets.FTP_USERNAME }} # FTP用户名
  28. ftp-password: ${{ secrets.FTP_PASSWORD }} # FTP密码
  29. git-ftp-args: --insecure --remote-root /home/www/htdocs # 要部署到服务器的哪个位置(我这用的是SFTP,如果是FTP连接的话--insecure不用加)
  30. local-dir: docs/.vuepress/dist/ # 选择哪些文件要部署到服务器,这个选项在这里选了之后,要在.git-ftp-include中添加相应的路径
  1. // .git-ftp-include
  2. !docs/.vuepress/dist/

添加Github Token

为了保密,把重要信息用变量表示,在Github Secrets中添加相应的值

仓库的Settings --> Secrets --> Add a new secret

比如

  • Name: FTP_USERNAME
  • Value: admin

最后再把代码上传到Github便可自动触发构建,部署到第三方服务器

本文由Tsanfer's Blog 发布!

vuepress-theme-reco + Github Actions 构建静态博客,部署到第三方服务器的更多相关文章

  1. 【一】Ubuntu14.04+Jekyll+Github Pages搭建静态博客

    本系列有五篇:分别是 [一]Ubuntu14.04+Jekyll+Github Pages搭建静态博客:主要是安装方面 [二]jekyll 的使用 :主要是jekyll的配置 [三]Markdown+ ...

  2. hexo搭建个人博客部署到个人服务器(git+nginx+hexo+next)

    本次以阿里云服务器为例,详细讲解步骤: 一.本地环境[客户端] 这里以本地的win10电脑为例 1.下载node, 默认安装,安装完成之后,node -v看看版本号 node下载 2.安装node(傻 ...

  3. 使用 GitHub Actions 实现 Hexo 博客自动部署

    一.Hexo 相关知识点 静态博客简单,但是发布博文时稍显麻烦,一般需要下面两步: hexo clean hexo g -d // 相当于 hexo g + hexo d 如果考虑到同步源文件,还需要 ...

  4. 在windows下创建基于github的hexo静态博客

    最近边上的人都突然买起了域名搭起了个人网站,渣渣的我介于期末没事干也跟风搭了个静态博客.虽说博客基本不更新T T,嘛嘛回归正题. 首先准备工作: 1)安装nodejs 2)安装msysgit(虽然现在 ...

  5. 通过hexo+NexT构建静态博客

    一般的教程网上有很多,主要讲下我遇到的问题以及解决方法: 一.hexo建立的文档无法上传github deploy: type: git repository: https://github.com/ ...

  6. Github+Hexo搭建静态博客

    开始 在安装hexo之前,必须确认你已经安装了Node.js和Git,并且注册了一个Github账号. 1.创建Github仓库 1) 仓库名为xxx.github.io 创建一个以"用户名 ...

  7. 使用 Hexo,Material Theme 以及 Github Pages 搭建个人博客

    准备条件 Node.js npm Git GitHub账号 开始搭建 hexo init Blog cd Blog npm install hexo-deployer-git --save npm i ...

  8. Hexo博客部署到个人服务器

    本文跳过阿里云创建git仓库.hexo部署到github的步骤,有需要的可以移步下面博客地址查看: 在阿里云服务器上创建git远程仓库 使用Hexo建立博客 一.服务器相关配置 本文使用hexo在本地 ...

  9. 我在GitHub Pages托管静态博客啦~

    https://jinhengyu.github.io/

随机推荐

  1. 吴裕雄--天生自然python学习笔记:Python3 MySQL 数据库连接 - PyMySQL 驱动

    什么是 PyMySQL? PyMySQL 是在 Python3.x 版本中用于连接 MySQL 服务器的一个库,Python2中则使用mysqldb. PyMySQL 遵循 Python 数据库 AP ...

  2. struts2学习笔记之十四:使用注解配置Action(不是和spring集成使用)

    Struts2支持使用注解配置Action,减少配置文件的配置 Struts2如果要支持注解配置Action,需要插件的支持,导入插件struts2-convention-plugin-2.1.8.1 ...

  3. Heartbeat(注意iptables和selinux的问题)

    安装 yum –y install heartbeat libnet配置 通过yum安装配置文件目录/etc/ha.d目录下没有配置文件需要从doc目录中复制三个文件.ha.cf.authkeys.h ...

  4. 吴裕雄--天生自然KITTEN编程:救救小兔子

  5. Leetcode 063 不同路径二

    一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为"Start" ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在下图中标记为" ...

  6. 以后的IT路还很长(1)

    以后的IT路还很长(1) 最近有两位兄弟同事离职了,蛮可惜了,在一个战壕一起一.两年了,人各有志嘛!希望他们发展更好些! 目前的公司是个创业型的公司,公司从08年的50来个人,扩张到今年11年400多 ...

  7. 迈克尔·乔丹:几百年内AI不会觉醒

    ​​ 此乔丹非飞人乔丹.他是研究统计学和计算机科学家,目前研究的领域正是普通人所说的人工智能.权威的学术搜索引擎Semantic Scholar在2105年做了一项排名,关于计算机科学领域谁最具影响力 ...

  8. mongodb 修改oplogSize

    oplog是local库下的一个固定集合,Secondary就是通过查看Primary的oplog这个集合来进行复制的.每个节点都有oplog,记录从主节点复制过来的信息,这样每个成员都可以作为同步源 ...

  9. Internet上的音频/视频概述

    Internet上的音频/视频概述 计算机网络最初是为传送数据信息设计的.因特网 IP 层提供的"尽最大努力交付"服务,以及每一个分组独立交付的策略,对传送数据信息也是很合适的. ...

  10. USB小白学习之路(4)HID键盘程序

    HID键盘程序 1. 特别注意 需要特别注意,各个例程中的设备描述符,配置描述符等各种描述符都是已经配置好了的,我们需要做的只是在例程中将代码修改为自己需要的部分即可,一般情况下是不可以串搭配的. 2 ...