Code Monkey home page Code Monkey logo

blog-template's Introduction

blog-template

介绍

基于 VuePress 的静态博客生成器,主题为:vuepress-theme-reco

已完以下配置:

  1. 评论模块。使用 valine,请自行配置 appId 及 appKey。
  2. seo 的配置。参考https://www.geekzl.com/vuepress-seo-tips.html
  3. 访问量。

使用方法

非常简单。

  1. 克隆本项目。
git clone https://github.com/somenzz/blog-template.git
  1. 运行看效果,修改成自己满意的配置。
cd blog-template
npm install && npm run dev

配置文件位于为 docs/.vuepress,请逐行检查,把博客名称,描述,图片位置,颜色配置等,改成自己满意的的即可。

评论取的 appId、appKey 见 docs/.vuepress/config/theme/index.js 文件,请先去 valine,申请自己的 appId 及 appKey。

  1. 写博客。
cd blog-template
vi docs/blog/2021/blog.md
npm run build
  1. 提交到自己的 xxx.github.io 仓库。

先在 github 上创建一个 xxx.github.io 仓库

cd blog-template/public
git init
git add .
git commit -m "add article"
git push --force https://github.com/xxx/xxx.github.io.git master #可以强制提交,这个仓库仅保留静态文件

push 之后去 xxx.github.io 仓库的设置页面,设置 githup pages 指定 master 分支的 root 路径即可。

看到一些人会使用同一个仓库设置两个分支,比如说 master 用于写博客,gh-pages 用于保存静态资源。

我反对这种做法,因为这违背了 github 分支的用途,一般 master 分支不够用的时候,我们创建 develop 分支,用于开发时,修改任何代码不会影响 master 分支,开发、测试完成,形成稳定版本,再将 develop 分支合并到 master 分支,其实 master 和 develop 就是同一个仓库的两个指针,指向不同的时间点,所谓的合并就是将 master 的指针指向 develop 的位置。

而本应用中 master 存放写博客的脚手架,如 md 文件,VuePress 等配置信息,gh-pages 只存放静态文件,两个仓库的文件没有任何共同之处,应该使用两个仓库,而不是两个分支。而且就算用,这两个分支也永远没有合并的可能,何况这样做相当麻烦,每次提交到 gh-pages 你都需要先切换到 gh-pages 分支,然后将 master 分支下的 .git 文件夹先移走,提交完在移动回来。

  1. 访问自己的博客,比如 https://somenzz.github.io

  2. 如果需要提交后自动部署,请参考我的文章 GitHub Actions入门教程:自动化部署静态博客

最后

静态博客部署是 0 成本,高效率,无需担心网络安全等问题,值得每一个写作者尝试,省下的精力可以专心写作,此外,你也可以申请一个个性的域名直接指向 xxx.github.io 这个网站,比如我的 https://somenzz.cn

如果觉得本文不错,欢迎关注我的公众号「Python七号」,有任何问题,都可以公众号回复问题咨询哦。

blog-template's People

Contributors

somenzz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.