如何拥有个人的Github技术博客

2023-10-26

0?wx_fmt=png

题图:87testing.com


前不久用wordpress搭建了一个博客,用起来感觉不是太好用,并且数据库经常会发生异常挂掉,没找到解决方案。


看到有不少人使用的hexo+github方式搭建属于自己的博客,

于是,我也做了一些尝试,将搭建的过程整理出来,希望也能帮到他人。


同时,推荐没有Blog的朋友也尝试自己搭建下,中间可能会遇到一些问题,解决问题的过程很痛苦,但是只要爱折腾,最终都能迎刃而解。


一、环境准备


1、安装git (https://git-scm.com/downloads) 安装目的:用来把本地的hexo内容push到github上。

2、安装node(https://nodejs.org/en/download/)安装目的:用来生成静态页面

3、申请github账号(https://github.com/) ssh keys相关的配置之前介绍过,这里就不过多描述:http://www.87testing.com/2017/07/02/pycharm-e5-85-b3-e8-81-94github/



二、安装hexo


1、创建一个文件夹blog,进入到这个blog目录,安装hexo,执行:sudo npm install -g hexo


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ sudo npm install -g hexo

Password:

npm WARN deprecated swig@1.4.2: This package is no longer maintained

/usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo/bin/hexo


> dtrace-provider@0.8.5 install /usr/local/lib/node_modules/hexo/node_modules/dtrace-provider

> node scripts/install.js



> fsevents@1.1.2 install /usr/local/lib/node_modules/hexo/node_modules/fsevents

> node install


[fsevents] Success: "/usr/local/lib/node_modules/hexo/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed

Pass --update-binary to reinstall or --build-from-source to recompile


> hexo-util@0.6.1 postinstall /usr/local/lib/node_modules/hexo/node_modules/hexo-util

> npm run build:highlight



> hexo-util@0.6.1 build:highlight /usr/local/lib/node_modules/hexo/node_modules/hexo-util

> node scripts/build_highlight_alias.js > highlight_alias.json


/usr/local/lib

└─┬ hexo@3.3.8 

  ├── abbrev@1.1.0 

  ├── archy@1.0.0 

  ├── bluebird@3.5.0 

  ├─┬ chalk@1.1.3 

  │ ├── ansi-styles@2.2.1 

  │ ├── escape-string-regexp@1.0.5 

  │ ├─┬ has-ansi@2.0.0 

  │ │ └── ansi-regex@2.1.1 

  │ ├── strip-ansi@3.0.1 

  │ └── supports-color@2.0.0 

  ├─┬ cheerio@0.20.0 

  │ ├─┬ css-select@1.2.0 

  │ │ ├── boolbase@1.0.0 

  │ │ ├── css-what@2.1.0 

  │ │ ├── domutils@1.5.1 

  │ │ └── nth-check@1.0.1 

  │ ├─┬ dom-serializer@0.1.0 

  │ │ └── domelementtype@1.1.3 

  │ ├── entities@1.1.1 

  │ ├─┬ htmlparser2@3.8.3 

  │ │ ├── domelementtype@1.3.0 

  │ │ ├── domhandler@2.3.0 

  │ │ ├── entities@1.0.0 

  │ │ └─┬ readable-stream@1.1.14 

  │ │   ├── core-util-is@1.0.2 

  │ │   ├── isarray@0.0.1 

  │ │   └── string_decoder@0.10.31 

  │ └─┬ jsdom@7.2.2 

  │   ├── abab@1.0.3 

  │   ├── acorn@2.7.0 

  │   ├── acorn-globals@1.0.9 

  │   ├── cssom@0.3.2 

  │   ├── cssstyle@0.2.37 

  │   ├─┬ escodegen@1.8.1 

  │   │ ├── esprima@2.7.3 

  │   │ ├── estraverse@1.9.3 

  │   │ ├── esutils@2.0.2 

  │   │ ├─┬ optionator@0.8.2 

  │   │ │ ├── deep-is@0.1.3 

  │   │ │ ├── fast-levenshtein@2.0.6 

  │   │ │ ├── levn@0.3.0 

  │   │ │ ├── prelude-ls@1.1.2 

  │   │ │ ├── type-check@0.3.2 

  │   │ │ └── wordwrap@1.0.0 

  │   │ └── source-map@0.2.0 

  │   ├── nwmatcher@1.4.1 

  │   ├── parse5@1.5.1 

  │   ├─┬ request@2.81.0 

  │   │ ├── aws-sign2@0.6.0 

  │   │ ├── aws4@1.6.0 

  │   │ ├── caseless@0.12.0 

  │   │ ├─┬ combined-stream@1.0.5 

  │   │ │ └── delayed-stream@1.0.0 

  │   │ ├── extend@3.0.1 

  │   │ ├── forever-agent@0.6.1 

  │   │ ├─┬ form-data@2.1.4 

  │   │ │ └── asynckit@0.4.0 

  │   │ ├─┬ har-validator@4.2.1 

  │   │ │ ├─┬ ajv@4.11.8 

  │   │ │ │ ├── co@4.6.0 

  │   │ │ │ └─┬ json-stable-stringify@1.0.1 

  │   │ │ │   └── jsonify@0.0.0 

  │   │ │ └── har-schema@1.0.5 

  │   │ ├─┬ hawk@3.1.3 

  │   │ │ ├── boom@2.10.1 

  │   │ │ ├── cryptiles@2.0.5 

  │   │ │ ├── hoek@2.16.3 

  │   │ │ └── sntp@1.0.9 

  │   │ ├─┬ http-signature@1.1.1 

  │   │ │ ├── assert-plus@0.2.0 

  │   │ │ ├─┬ jsprim@1.4.1 

  │   │ │ │ ├── assert-plus@1.0.0 

  │   │ │ │ ├── extsprintf@1.3.0 

  │   │ │ │ ├── json-schema@0.2.3 

  │   │ │ │ └─┬ verror@1.10.0 

  │   │ │ │   └── assert-plus@1.0.0 

  │   │ │ └─┬ sshpk@1.13.1 

  │   │ │   ├── asn1@0.2.3 

  │   │ │   ├── assert-plus@1.0.0 

  │   │ │   ├── bcrypt-pbkdf@1.0.1 

  │   │ │   ├─┬ dashdash@1.14.1 

  │   │ │   │ └── assert-plus@1.0.0 

  │   │ │   ├── ecc-jsbn@0.1.1 

  │   │ │   ├─┬ getpass@0.1.7 

  │   │ │   │ └── assert-plus@1.0.0 

  │   │ │   ├── jsbn@0.1.1 

  │   │ │   └── tweetnacl@0.14.5 

  │   │ ├── is-typedarray@1.0.0 

  │   │ ├── isstream@0.1.2 

  │   │ ├── json-stringify-safe@5.0.1 

  │   │ ├─┬ mime-types@2.1.16 

  │   │ │ └── mime-db@1.29.0 

  │   │ ├── oauth-sign@0.8.2 

  │   │ ├── performance-now@0.2.0 

  │   │ ├── qs@6.4.0 

  │   │ ├── safe-buffer@5.1.1 

  │   │ ├── stringstream@0.0.5 

  │   │ ├── tunnel-agent@0.6.0 

  │   │ └── uuid@3.1.0 

  │   ├── sax@1.2.4 

  │   ├── symbol-tree@3.2.2 

  │   ├─┬ tough-cookie@2.3.2 

  │   │ └── punycode@1.4.1 

  │   ├── webidl-conversions@2.0.1 

  │   ├─┬ whatwg-url-compat@0.6.5 

  │   │ └── tr46@0.0.3 

  │   └── xml-name-validator@2.0.1 

  ├─┬ deep-assign@2.0.0 

  │ └── is-obj@1.0.1 

  ├─┬ hexo-cli@1.0.3 

  │ ├── command-exists@1.2.2 

  │ ├── minimist@1.2.0 

  │ └── object-assign@4.1.1 

  ├── hexo-front-matter@0.2.3 

  ├─┬ hexo-fs@0.2.1 

  │ ├─┬ chokidar@1.7.0 

  │ │ ├─┬ anymatch@1.3.2 

  │ │ │ ├─┬ micromatch@2.3.11 

  │ │ │ │ ├─┬ arr-diff@2.0.0 

  │ │ │ │ │ └── arr-flatten@1.1.0 

  │ │ │ │ ├── array-unique@0.2.1 

  │ │ │ │ ├─┬ braces@1.8.5 

  │ │ │ │ │ ├─┬ expand-range@1.8.2 

  │ │ │ │ │ │ └─┬ fill-range@2.2.3 

  │ │ │ │ │ │   ├── is-number@2.1.0 

  │ │ │ │ │ │   ├─┬ isobject@2.1.0 

  │ │ │ │ │ │   │ └── isarray@1.0.0 

  │ │ │ │ │ │   ├─┬ randomatic@1.1.7 

  │ │ │ │ │ │   │ ├─┬ is-number@3.0.0 

  │ │ │ │ │ │   │ │ └── kind-of@3.2.2 

  │ │ │ │ │ │   │ └── kind-of@4.0.0 

  │ │ │ │ │ │   └── repeat-string@1.6.1 

  │ │ │ │ │ ├── preserve@0.2.0 

  │ │ │ │ │ └── repeat-element@1.1.2 

  │ │ │ │ ├─┬ expand-brackets@0.1.5 

  │ │ │ │ │ └── is-posix-bracket@0.1.1 

  │ │ │ │ ├── extglob@0.3.2 

  │ │ │ │ ├── filename-regex@2.0.1 

  │ │ │ │ ├─┬ kind-of@3.2.2 

  │ │ │ │ │ └── is-buffer@1.1.5 

  │ │ │ │ ├─┬ object.omit@2.0.1 

  │ │ │ │ │ ├─┬ for-own@0.1.5 

  │ │ │ │ │ │ └── for-in@1.0.2 

  │ │ │ │ │ └── is-extendable@0.1.1 

  │ │ │ │ ├─┬ parse-glob@3.0.4 

  │ │ │ │ │ ├── glob-base@0.3.0 

  │ │ │ │ │ └── is-dotfile@1.0.3 

  │ │ │ │ └─┬ regex-cache@0.4.3 

  │ │ │ │   ├── is-equal-shallow@0.1.3 

  │ │ │ │   └── is-primitive@2.0.0 

  │ │ │ └─┬ normalize-path@2.1.1 

  │ │ │   └── remove-trailing-separator@1.0.2 

  │ │ ├── async-each@1.0.1 

  │ │ ├─┬ fsevents@1.1.2 

  │ │ │ ├── nan@2.6.2 

  │ │ │ └─┬ node-pre-gyp@0.6.36 

  │ │ │   ├─┬ mkdirp@0.5.1 

  │ │ │   │ └── minimist@0.0.8 

  │ │ │   ├─┬ nopt@4.0.1 

  │ │ │   │ ├── abbrev@1.1.0 

  │ │ │   │ └─┬ osenv@0.1.4 

  │ │ │   │   ├── os-homedir@1.0.2 

  │ │ │   │   └── os-tmpdir@1.0.2 

  │ │ │   ├─┬ npmlog@4.1.0 

  │ │ │   │ ├─┬ are-we-there-yet@1.1.4 

  │ │ │   │ │ └── delegates@1.0.0 

  │ │ │   │ ├── console-control-strings@1.1.0 

  │ │ │   │ ├─┬ gauge@2.7.4 

  │ │ │   │ │ ├── aproba@1.1.1 

  │ │ │   │ │ ├── has-unicode@2.0.1 

  │ │ │   │ │ ├── object-assign@4.1.1 

  │ │ │   │ │ ├── signal-exit@3.0.2 

  │ │ │   │ │ ├─┬ string-width@1.0.2 

  │ │ │   │ │ │ ├── code-point-at@1.1.0 

  │ │ │   │ │ │ └─┬ is-fullwidth-code-point@1.0.0 

  │ │ │   │ │ │   └── number-is-nan@1.0.1 

  │ │ │   │ │ ├─┬ strip-ansi@3.0.1 

  │ │ │   │ │ │ └── ansi-regex@2.1.1 

  │ │ │   │ │ └── wide-align@1.1.2 

  │ │ │   │ └── set-blocking@2.0.0 

  │ │ │   ├─┬ rc@1.2.1 

  │ │ │   │ ├── deep-extend@0.4.2 

  │ │ │   │ ├── ini@1.3.4 

  │ │ │   │ ├── minimist@1.2.0 

  │ │ │   │ └── strip-json-comments@2.0.1 

  │ │ │   ├─┬ request@2.81.0 

  │ │ │   │ ├── aws-sign2@0.6.0 

  │ │ │   │ ├── aws4@1.6.0 

  │ │ │   │ ├── caseless@0.12.0 

  │ │ │   │ ├─┬ combined-stream@1.0.5 

  │ │ │   │ │ └── delayed-stream@1.0.0 

  │ │ │   │ ├── extend@3.0.1 

  │ │ │   │ ├── forever-agent@0.6.1 

  │ │ │   │ ├─┬ form-data@2.1.4 

  │ │ │   │ │ └── asynckit@0.4.0 

  │ │ │   │ ├─┬ har-validator@4.2.1 

  │ │ │   │ │ ├─┬ ajv@4.11.8 

  │ │ │   │ │ │ ├── co@4.6.0 

  │ │ │   │ │ │ └─┬ json-stable-stringify@1.0.1 

  │ │ │   │ │ │   └── jsonify@0.0.0 

  │ │ │   │ │ └── har-schema@1.0.5 

  │ │ │   │ ├─┬ hawk@3.1.3 

  │ │ │   │ │ ├── boom@2.10.1 

  │ │ │   │ │ ├── cryptiles@2.0.5 

  │ │ │   │ │ ├── hoek@2.16.3 

  │ │ │   │ │ └── sntp@1.0.9 

  │ │ │   │ ├─┬ http-signature@1.1.1 

  │ │ │   │ │ ├── assert-plus@0.2.0 

  │ │ │   │ │ ├─┬ jsprim@1.4.0 

  │ │ │   │ │ │ ├── assert-plus@1.0.0 

  │ │ │   │ │ │ ├── extsprintf@1.0.2 

  │ │ │   │ │ │ ├── json-schema@0.2.3 

  │ │ │   │ │ │ └── verror@1.3.6 

  │ │ │   │ │ └─┬ sshpk@1.13.0 

  │ │ │   │ │   ├── asn1@0.2.3 

  │ │ │   │ │   ├── assert-plus@1.0.0 

  │ │ │   │ │   ├── bcrypt-pbkdf@1.0.1 

  │ │ │   │ │   ├─┬ dashdash@1.14.1 

  │ │ │   │ │   │ └── assert-plus@1.0.0 

  │ │ │   │ │   ├── ecc-jsbn@0.1.1 

  │ │ │   │ │   ├─┬ getpass@0.1.7 

  │ │ │   │ │   │ └── assert-plus@1.0.0 

  │ │ │   │ │   ├── jodid25519@1.0.2 

  │ │ │   │ │   ├── jsbn@0.1.1 

  │ │ │   │ │   └── tweetnacl@0.14.5 

  │ │ │   │ ├── is-typedarray@1.0.0 

  │ │ │   │ ├── isstream@0.1.2 

  │ │ │   │ ├── json-stringify-safe@5.0.1 

  │ │ │   │ ├─┬ mime-types@2.1.15 

  │ │ │   │ │ └── mime-db@1.27.0 

  │ │ │   │ ├── oauth-sign@0.8.2 

  │ │ │   │ ├── performance-now@0.2.0 

  │ │ │   │ ├── qs@6.4.0 

  │ │ │   │ ├── safe-buffer@5.0.1 

  │ │ │   │ ├── stringstream@0.0.5 

  │ │ │   │ ├─┬ tough-cookie@2.3.2 

  │ │ │   │ │ └── punycode@1.4.1 

  │ │ │   │ ├── tunnel-agent@0.6.0 

  │ │ │   │ └── uuid@3.0.1 

  │ │ │   ├─┬ rimraf@2.6.1 

  │ │ │   │ └─┬ glob@7.1.2 

  │ │ │   │   ├── fs.realpath@1.0.0 

  │ │ │   │   ├── inflight@1.0.6 

  │ │ │   │   ├─┬ minimatch@3.0.4 

  │ │ │   │   │ └─┬ brace-expansion@1.1.7 

  │ │ │   │   │   ├── balanced-match@0.4.2 

  │ │ │   │   │   └── concat-map@0.0.1 

  │ │ │   │   └── path-is-absolute@1.0.1 

  │ │ │   ├── semver@5.3.0 

  │ │ │   ├─┬ tar@2.2.1 

  │ │ │   │ ├── block-stream@0.0.9 

  │ │ │   │ ├─┬ fstream@1.0.11 

  │ │ │   │ │ └── graceful-fs@4.1.11 

  │ │ │   │ └── inherits@2.0.3 

  │ │ │   └─┬ tar-pack@3.4.0 

  │ │ │     ├─┬ debug@2.6.8 

  │ │ │     │ └── ms@2.0.0 

  │ │ │     ├── fstream-ignore@1.0.5 

  │ │ │     ├─┬ once@1.4.0 

  │ │ │     │ └── wrappy@1.0.2 

  │ │ │     ├─┬ readable-stream@2.2.9 

  │ │ │     │ ├── buffer-shims@1.0.0 

  │ │ │     │ ├── core-util-is@1.0.2 

  │ │ │     │ ├── isarray@1.0.0 

  │ │ │     │ ├── process-nextick-args@1.0.7 

  │ │ │     │ ├── string_decoder@1.0.1 

  │ │ │     │ └── util-deprecate@1.0.2 

  │ │ │     └── uid-number@0.0.6 

  │ │ ├── glob-parent@2.0.0 

  │ │ ├── inherits@2.0.3 

  │ │ ├─┬ is-binary-path@1.0.1 

  │ │ │ └── binary-extensions@1.9.0 

  │ │ ├─┬ is-glob@2.0.1 

  │ │ │ └── is-extglob@1.0.0 

  │ │ ├── path-is-absolute@1.0.1 

  │ │ └─┬ readdirp@2.1.0 

  │ │   ├─┬ readable-stream@2.3.3 

  │ │   │ ├── isarray@1.0.0 

  │ │   │ ├── process-nextick-args@1.0.7 

  │ │   │ ├── string_decoder@1.0.3 

  │ │   │ └── util-deprecate@1.0.2 

  │ │   └── set-immediate-shim@1.0.1 

  │ └── graceful-fs@4.1.11 

  ├─┬ hexo-i18n@0.2.1 

  │ └── sprintf-js@1.0.3 

  ├─┬ hexo-log@0.1.3 

  │ └─┬ bunyan@1.8.12 

  │   ├── dtrace-provider@0.8.5 

  │   ├─┬ mv@2.1.1 

  │   │ ├─┬ mkdirp@0.5.1 

  │   │ │ └── minimist@0.0.8 

  │   │ ├── ncp@2.0.0 

  │   │ └─┬ rimraf@2.4.5 

  │   │   └─┬ glob@6.0.4 

  │   │     ├─┬ inflight@1.0.6 

  │   │     │ └── wrappy@1.0.2 

  │   │     └── once@1.4.0 

  │   └── safe-json-stringify@1.0.4 

  ├─┬ hexo-util@0.6.1 

  │ ├─┬ camel-case@3.0.0 

  │ │ ├─┬ no-case@2.3.1 

  │ │ │ └── lower-case@1.1.4 

  │ │ └── upper-case@1.1.3 

  │ ├─┬ cross-spawn@4.0.2 

  │ │ ├─┬ lru-cache@4.1.1 

  │ │ │ ├── pseudomap@1.0.2 

  │ │ │ └── yallist@2.1.2 

  │ │ └─┬ which@1.3.0 

  │ │   └── isexe@2.0.0 

  │ ├── highlight.js@9.12.0 

  │ ├── html-entities@1.2.1 

  │ └── striptags@2.2.1 

  ├─┬ js-yaml@3.9.1 

  │ ├── argparse@1.0.9 

  │ └── esprima@4.0.0 

  ├── lodash@4.17.4 

  ├─┬ minimatch@3.0.4 

  │ └─┬ brace-expansion@1.1.8 

  │   ├── balanced-match@1.0.0 

  │   └── concat-map@0.0.1 

  ├── moment@2.13.0 

  ├── moment-timezone@0.5.13 

  ├─┬ nunjucks@2.5.2 

  │ ├── asap@2.0.6 

  │ └─┬ yargs@3.32.0 

  │   ├── camelcase@2.1.1 

  │   ├─┬ cliui@3.2.0 

  │   │ └── wrap-ansi@2.1.0 

  │   ├── decamelize@1.2.0 

  │   ├─┬ os-locale@1.4.0 

  │   │ └─┬ lcid@1.0.0 

  │   │   └── invert-kv@1.0.0 

  │   ├─┬ string-width@1.0.2 

  │   │ ├── code-point-at@1.1.0 

  │   │ └─┬ is-fullwidth-code-point@1.0.0 

  │   │   └── number-is-nan@1.0.1 

  │   ├── window-size@0.1.4 

  │   └── y18n@3.2.1 

  ├── pretty-hrtime@1.0.3 

  ├─┬ strip-indent@1.0.1 

  │ └── get-stdin@4.0.1 

  ├─┬ swig@1.4.2 

  │ ├─┬ optimist@0.6.1 

  │ │ ├── minimist@0.0.10 

  │ │ └── wordwrap@0.0.3 

  │ └─┬ uglify-js@2.4.24 

  │   ├── async@0.2.10 

  │   ├─┬ source-map@0.1.34 

  │   │ └── amdefine@1.0.1 

  │   ├── uglify-to-browserify@1.0.2 

  │   └─┬ yargs@3.5.4 

  │     ├── camelcase@1.2.1 

  │     ├── window-size@0.1.0 

  │     └── wordwrap@0.0.2 

  ├─┬ swig-extras@0.0.1 

  │ └─┬ markdown@0.5.0 

  │   └── nopt@2.1.2 

  ├── text-table@0.2.0 

  ├─┬ tildify@1.2.0 

  │ └── os-homedir@1.0.2 

  ├── titlecase@1.1.2 

  └─┬ warehouse@2.2.0 

    ├─┬ cuid@1.3.8 

    │ ├── browser-fingerprint@0.0.1 

    │ ├── core-js@1.2.7 

    │ └── node-fingerprint@0.0.2 

    ├─┬ is-plain-object@2.0.4 

    │ └── isobject@3.0.1 

    └─┬ JSONStream@1.3.1 

      ├── jsonparse@1.3.1 

      └── through@2.3.8 



2、初始化hexo,执行:hexo init


此时,blog目录就是博客的根目录,已经建立完成了。


3、生成静态页面,执行:hexo g(或者执行:hexo generate)


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ hexo g

INFO  Start processing

INFO  Files loaded in 408 ms

INFO  Generated: index.html

INFO  Generated: archives/index.html

INFO  Generated: fancybox/blank.gif

INFO  Generated: fancybox/jquery.fancybox.css

INFO  Generated: fancybox/jquery.fancybox.js

INFO  Generated: fancybox/jquery.fancybox.pack.js

INFO  Generated: fancybox/fancybox_loading.gif

INFO  Generated: fancybox/fancybox_loading@2x.gif

INFO  Generated: fancybox/fancybox_overlay.png

INFO  Generated: fancybox/fancybox_sprite.png

INFO  Generated: fancybox/fancybox_sprite@2x.png

INFO  Generated: archives/2017/08/index.html

INFO  Generated: archives/2017/index.html

INFO  Generated: css/fonts/FontAwesome.otf

INFO  Generated: js/script.js

INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.css

INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.js

INFO  Generated: fancybox/helpers/jquery.fancybox-media.js

INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.css

INFO  Generated: css/style.css

INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.js

INFO  Generated: css/fonts/fontawesome-webfont.eot

INFO  Generated: css/fonts/fontawesome-webfont.woff

INFO  Generated: fancybox/helpers/fancybox_buttons.png

INFO  Generated: css/images/banner.jpg

INFO  Generated: css/fonts/fontawesome-webfont.svg

INFO  Generated: css/fonts/fontawesome-webfont.ttf

INFO  Generated: 2017/08/10/hello-world/index.html

INFO  28 files generated in 1.41 s


4、本地启动hexo,执行:hexo server


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ hexo server

INFO  Start processing

INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.


浏览器输入http://localhost:4000,即可打开hexo博客页面:如图:

0?wx_fmt=png



此时只是完成了本地启动hexo,将本地的blog push到github上还需要本地跟github建立连接,接下来对github进行配置。



三、github配置


1、github上创建代码仓库


建立Repository,仓库名:yourname.github.io


2、然后再本地blog目录的_config.yml配置文件中最后一行增加如下配置:


deploy:

  type: git

  repo: https://github.com/TTtesting/tttesting.github.io.git

  branch: master

冒号后面记得加空格,不然会报错。


3、_congig.yml配置修改保存后,执行如下命令:

npm install hexo-deployer-git --save


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ npm install hexo-deployer-git --save

hexo-site@0.0.0 /Users/admin/software/blog

└─┬ hexo-deployer-git@0.3.1 

  ├─┬ babel-eslint@7.2.3 

  │ ├─┬ babel-code-frame@6.22.0 

  │ │ └── js-tokens@3.0.2 

  │ ├─┬ babel-traverse@6.25.0 

  │ │ ├── babel-messages@6.23.0 

  │ │ ├─┬ babel-runtime@6.25.0 

  │ │ │ ├── core-js@2.5.0 

  │ │ │ └── regenerator-runtime@0.10.5 

  │ │ ├── debug@2.6.8 

  │ │ ├── globals@9.18.0 

  │ │ └─┬ invariant@2.2.2 

  │ │   └── loose-envify@1.3.1 

  │ ├─┬ babel-types@6.25.0 

  │ │ └── to-fast-properties@1.0.3 

  │ └── babylon@6.17.4 

  └── moment@2.18.1 


4、执行配置命令:

TTZhangdeMacBook-Pro:blog admin$ hexo deploy

INFO  Deploying: git

INFO  Setting up Git deployment...

Initialized empty Git repository in /Users/admin/software/blog/.deploy_git/.git/

[master (root-commit) d37715b] First commit

 1 file changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 placeholder

INFO  Clearing .deploy_git folder...

INFO  Copying files from public folder...

INFO  Copying files from extend dirs...

[master 28f7f04] Site updated: 2017-08-10 21:52:38

 29 files changed, 5758 insertions(+)

 create mode 100644 2017/08/10/hello-world/index.html

 create mode 100644 archives/2017/08/index.html

 create mode 100644 archives/2017/index.html

 create mode 100644 archives/index.html

 create mode 100644 css/fonts/FontAwesome.otf

 create mode 100644 css/fonts/fontawesome-webfont.eot

 create mode 100644 css/fonts/fontawesome-webfont.svg

 create mode 100644 css/fonts/fontawesome-webfont.ttf

 create mode 100644 css/fonts/fontawesome-webfont.woff

 create mode 100644 css/images/banner.jpg

 create mode 100644 css/style.css

 create mode 100644 fancybox/blank.gif

 create mode 100644 fancybox/fancybox_loading.gif

 create mode 100644 fancybox/fancybox_loading@2x.gif

 create mode 100644 fancybox/fancybox_overlay.png

 create mode 100644 fancybox/fancybox_sprite.png

 create mode 100644 fancybox/fancybox_sprite@2x.png

 create mode 100644 fancybox/helpers/fancybox_buttons.png

 create mode 100644 fancybox/helpers/jquery.fancybox-buttons.css

 create mode 100644 fancybox/helpers/jquery.fancybox-buttons.js

 create mode 100644 fancybox/helpers/jquery.fancybox-media.js

 create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.css

 create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.js

 create mode 100644 fancybox/jquery.fancybox.css

 create mode 100644 fancybox/jquery.fancybox.js

 create mode 100644 fancybox/jquery.fancybox.pack.js

 create mode 100644 index.html

 create mode 100644 js/script.js

 delete mode 100644 placeholder

To https://github.com/TTtesting/tttesting.github.io.git

 * [new branch]      HEAD -> master

Branch master set up to track remote branch master from https://github.com/TTtesting/tttesting.github.io.git.

INFO  Deploy done: git


此时本地与gitbub仓库已建立连接,浏览器中输入:https://tttesting.github.io,即可打开blog ,如图:

0?wx_fmt=png



四、更新本地修改到github


本地修改后每次部署的步骤,可按以下三步来进行。


    hexo clean


    hexo generate


    hexo deploy


一些常用命令:


hexo new"postName" #新建文章


hexo new page"pageName" #新建页面


hexo generate #生成静态页面至public目录


hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)


hexo deploy #将.deploy目录部署到GitHub


hexo help # 查看帮助


hexo version #查看Hexo的版本



五、博客首页显示所有文章列表配置


1、请确保node版本大于6.2

2、在博客根目录执行命令:npm i hexo-generator-json-content --save

3、在根目录_config.yml里添加配置:

  jsonContent:

    meta: false

    pages: false

    posts:

      title: true

      date: true

      path: true

      text: false

      raw: false

      content: false

      slug: false

      updated: false

      comments: false

      link: false

      permalink: false

      excerpt: false

      categories: false

      tags: true



最后,


给大家呈现出我的博客地址,如果只要借助github,就可使用github域名:https://tttesting.github.io


同时,有服务器的可以部署在自己的服务器上,使用自己申请的域名,欢迎访问我的博客:http://www.87testing.com


请加入测试技术分享圈,开始您的学习之旅吧!



长按二维码 一键加入  640?wx_fmt=jpeg

87testing.com

长按识别二维码加入:测试技术分享圈

640?wx_fmt=png



本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何拥有个人的Github技术博客 的相关文章

  • 提供HTTP、HTTPS都可访问的API

    情景说明 考虑到数据的安全传输 现在用到HTTPS进行API调用的越来越多了 本节就介绍如何使自己编写的API能让别人 进行HTTP HTTPS调用 先看一下一般情况 正常编写一个 使用HTTP访问一下 不写的话 默认使用HTTP协议进行访
  • 八、模板方法模式

    定义 模板方法模式 在一个方法中定义一个算法骨架 而将一些步骤延迟到子类中 模板方法使得子类可以在不改变算法结构的情况下 重新定义算法中的某些步骤 UML类图 说明 1 AbstractClass抽象中包含了模板方法 primitiveOp
  • ERC20的创建及合约之间的调用(合约调用合约)

    ERC20 Token ERC20是一个token合约标准 具体的概念和友好的合约库 可参考openzeppelin 接下来的代码创建一个erc20 token SPDX License Identifier GPL 3 0 pragma
  • webupload 实现大文件分片上传

    废话不多说 直接上例子 html代码 div class layui form item div
  • 1.Ros初学笔记

    1 创建workspace 名字是catkin ws mkdir p catkin ws src 2 初始化环境 生成build 编译成功的可执行文件 devel src 代码包 cd catkin ws catkin make 3 为了让
  • Ubuntu JetBrains(JetBrains Account Error:JetBrains Account connection error: www.jetbrains.com)

    问题 Your host may be behind a proxy 在使用学生免费账户登录的时候出现错误 解决 修改 etc hosts文件 将其中的 jetbrains的相关行去掉即可
  • Over-COM:一种可折叠的头部医疗支架

    为了帮助医生对颅内疾病进行更精准的诊断 来自中国的Lailu Li科研团队设计了一个架空可折叠的头部支架 Over COM 该支架包括一个固定在患者头部的装置 外壳 8个线性执行器和1个IMU 惯性测量单元 以及一个远离病人的小盒子 包含微
  • Doc2vec计算文本相似度

    1 Doc2vec模型介绍 Doc2Vec模型基于Word2vec模型 并在其基础上增加了一个段落向量 以Doc2Vec的C BOW方法为例 算法的主要思想在以下两个方面 训练过程中新增了paragraph id 即训练语料中每个句子都有一
  • java栈与队列

    3 栈 栈是一种特殊的线性表 栈只能在一端 栈顶 进行操作 往栈里添加元素叫入栈 删除栈里的元素叫出栈 后进的元素先出 官方栈 java util Stack 栈的应用 浏览器的前进与后退 如果输入三个网址 假设123三个 出栈过程 后退操
  • SpringCloud服务间调用

    SpringCloud服务间的调用有两种方式 RestTemplate和FeignClient 不管是什么方式 他都是通过REST接口调用服务的http接口 参数和结果默认都是通过jackson序列化和反序列化 因为Spring MVC的R
  • 修改jar包增加自己需要功能的操作步骤(小白实践)

    一 修改静态文件的方式比较简单 1 先将要修改的jar包备份 cp xxx jar xxx 2 jar 2 建立一个新的目录便于后面的打包 mkdir jar tmp 3 将包放到刚刚创建的目录里解压 mv xxx 2 jar jar tm
  • GUI系统之SurfaceFlinger(11)SurfaceComposerClient

    文章都是通过阅读源码分析出来的 还在不断完善与改进中 其中难免有些地方理解得不对 欢迎大家批评指正 转载请注明 From LXS http blog csdn net uiop78uiop78 GUI系统之SurfaceFlinger章节目
  • qwtplot3D安装--终结解决方案

    帮同学做一个地热信息展示的软件 需要用到3D显示的内容 一方面 自己比较懒 懒去看OpenGL相关的内容 虽然以前做过3D开发相关的内容 但是毕竟需要处理的代码太多了 另一方面 也是一直在用QWT在帮他做2D图形显示这块 因此就想着用qwt
  • python3面向对象

    一些术语 类 class 用来描述具有相同的属性和方法的对象的集合 它定义了该集合中每个对象所共有的属性和方法 对象是类的实例 an example 4 learning class nClass i 123456
  • 论文笔记1——SSDA-YOLO: SEMI-SUPERVISED DOMAIN ADAPTIVE YOLO FOR CROSS-DOMAIN OBJECT DETECTION

    SSDA YOLO SEMI SUPERVISED DOMAIN ADAPTIVE YOLO FOR CROSS DOMAIN OBJECT DETECTION 源码地址 https github com hnuzhy SSDA YOLO
  • c#中“?”的几种用法

    c 中 的几种用法 1 可空类型修饰符 如 A B表示如果A为null则返回B 否则返回A 2 三元运算符 如 bool f false return f true 1 0 如果f为true则返回1 否则返回0 3 空合并运算符 如 a b
  • MySQL 管理方法

    MySQL 管理方法 一 Mysql介绍 二 Mysql启动 三 Mysql用户管理 一 Mysql介绍 MySQL是一个开放源码的小型关联式数据库管理系统 开发者为瑞典MySQL AB公司 目前MySQL被广泛地应用在Internet上的
  • Pytest系列-使用自定义标记mark(6)

    简介 pytest 可以支持自定义标记 自定义标记可以把一个 web 项目划分为多个模块 然后指定模块名称执行 Pytest 里面自定义标记 用法 将 pytest mark 标记名称 放到测试函数或者类上面 使用 执行时加上 m 标记名
  • 单片机新手指导1:STM32单片机学习思路

    学习内容 1 写在前面 1 学习态度 单片机 编程学习需要持续的恒心和毅力 涉及的学科跨度大 知识多 前期需长期投入大的精力入门 整个学习过程中最难的是入门这一步 也就是从0到1的过程 后期的学习是从1到10 由于掌握了一定的学习方法 所以
  • 真题详解(有向图)-软件设计(六十二)

    真题详解 极限编程 软件设计 六十一 https blog csdn net ke1ying article details 130435971 CMM指软件成熟度模型 一般1级成熟度最低 5级成熟度最高 采用更高级的CMM模型可以提高软件

随机推荐

  • 2022最简单易懂的IOS App打包发布完整流程

    创建appid标识符 进入apple开发者中心点击Account 点击Certificates Identifiers Profiles 创建AppIDS标识符 点击左侧菜单栏Identifiers 再点击 按钮 选择App IDs 再点击
  • python批量 txt转xml_Python版YOLOV3 Label(.txt)文件转xml文件

    最近在训练自己的yolo模型 训练之后想算mAP 发现网络上基本都是VOC数据集的标签制作方法 我的标签一开始是这样的 类型 x y w h 所以和VOC的不一样 于是就自己做xml文件 附代码 from xml dom minidom i
  • 栈溢出及解决方法

    栈溢出及解决方法 文章目录 栈溢出及解决方法 1 什么是栈溢出 2 栈溢出的解决方法 1 什么是栈溢出 缓冲区溢出是由于C语言系列设有内置检查机制来确保复制到缓冲区的数据不得大于缓冲区的大小 因此当这个数据足够大的时候 将会溢出缓冲区的范围
  • IC SPEC相关数据

    恢复内容开始 静态电流 静态电流是指没有信号输入时的电流 也就是器件本身在不受外部因素影响下的本身消耗电流 纹波电压的害处 1 容易在用设备中产生不期望的谐波 而谐波会产生较多的危害 2 降低了电源的效率 3 较强的纹波会造成 浪涌电压或电
  • c++中string类与字符串数组

    strlen及用 给c 字符串数组赋值 strlen 很笨 它会在遇到 0之前一直找下去 所以在cstr2中没有 0的时候 它会一直找下去 而那些地方还没有被初始化过 所以就是乱的 而且strlen计算出的字符串数组长度是不包含 0的那部分
  • elasticsearch中mapping中的可设置的属性

    mappings 在index 库 下创建时使用 下面可以有多个mapping 以下数据结构主要针对每个mapping进行说明 一级属性 二级属性 三级属性 说明 dynamic 新增字段自动模式 true 表示自动识别新字段并创建索引 f
  • 动态爬虫(ajax)-爬取bilibili热门视频信息

    文章目录 前言 一 页面分析 二 编写爬虫 1 引入库 2 发出请求 2 1生成请求头 2 2发出请求并获取响应 3 解析响应的内容 4 保存提取的信息到本地 5 康康主函数 三 运行结果 前言 使用python爬虫爬取bilibli每日热
  • VS2019利用Developer Command Prompt for VS 2019查看对象模型中的Class

    本文利用Developer Command Prompt for VS 2019工具 快速查看对象模型中类的结构 便于大家迅速了解衍生类和基类的关系 文章目录 一 打开开发人员命令提示工具 二 使用步骤 1 确定cpp文件位置 1 1 查找
  • chatGPT侧边栏历史记录消失解决方法

    从昨天3月8日开始 很多程序员发现自己的chatGPT打开后左侧侧边栏历史记录消失了 自己辛辛苦苦测试的Prompt都没有了 折腾了很久都不行 不得不重新写Prompt 解决方法 其实很简单 就是退出账号登录 然后重新登录账号再刷新就恢复了
  • QT界面UI文件不读取问题

    QT的C 项目有一段时间没有打开 重新打开时发现部分ui界面不知道为什么无法在QT Creator中用designer编辑器打开了 问题如下图 1 双击该ui界面不会自动跳转到界面编辑器了 2 可以随意更改ui界面的代码内容了 正常的ui界
  • C/C++使用Windows的API实现共享内存以及同步

    目录 共享内存 事件 Event 实现思路 创建方 服务端 连接方 进程同步 windows的API CreateFileMapping MapViewOfFile CreateEvent WaitForSingleObject Creat
  • 复习js笔记

    JS w3cschool官网 1000多本编程教程免费学 在日常中遇到的js函数 forms document forms name for in 循环 let x name lai age 18 city nanyang var y fo
  • 深度学习:激活函数的比较和优缺点,sigmoid,tanh,relu

    1 什么是激活函数 2 为什么要用 3 都有什么激活函数 4 sigmoid Relu softmax 1 什么是激活函数 如下图 在神经元中 输入的 inputs 通过加权 求和后 还被作用了一个函数 这个函数就是激活函数 Activat
  • Vue

    一 vue router的实现原理 路由的概念来源于服务端 服务端中的路由描述的是URL和处理函数之间的映射关系 web前端单页应用SPA single page application 中 路由描述的是URL和UI之前的映射关系 这种映射
  • 华为机试题24-合唱队

    描述 N 位同学站成一排 音乐老师要请最少的同学出列 使得剩下的 K 位同学排成合唱队形 设K位同学从左到右依次编号为 1 2 K 他们的身高分别为T1 T2 TK 若存在i 1 i K 使得T1
  • 万字解读区块链游戏行业:洞察游戏的未来

    撰文 Mason Nystrom Jerry Sun Messari 分析师 编辑 南风 基于区块链的游戏领域正在快速扩张 这得益于 NFT 和游戏内货币的崛起 该领域的增长可以被视为数十年来游戏行业盈利策略和商业模式不断迭代的延续 在过去
  • VB--生成DLL的步骤

    1 找到工程栏下 当前工程 选中它 2 右键工程 属性 3 生成页签 改下版本号 以便区分 4 选择横的菜单栏 文件 生成 dll 文件 OVER
  • 驱动开发 linux内核GPIO子系统、及其新版API的概念和使用,linux内核定时器

    1 GPIO子系统 概述 每一个芯片厂商生产出芯片后会给linux提供一个当前芯片中gpio外设的驱动 我们只需要调用对应的厂商驱动就可以完成硬件的控制 而linux内核源码中的gpio厂商驱动有很多 linux内核个会对厂商驱动做一些封装
  • 【HIve】java.lang.NoSuchFieldError: HIVE_STATS_JDBC_TIMEOUT

    1 概述 xception in thread main java lang NoSuchFieldError HIVE STATS JDBC TIMEOUT at org apache spark sql hive HiveUtils h
  • 如何拥有个人的Github技术博客

    题图 87testing com 前不久用wordpress搭建了一个博客 用起来感觉不是太好用 并且数据库经常会发生异常挂掉 没找到解决方案 看到有不少人使用的hexo github方式搭建属于自己的博客 于是 我也做了一些尝试 将搭建的