github page with vite
-
create a vite project
-
create a repository on github
-
add remote repository
-
install gh-pages
npm install gh-pages --save-dev
-
add deploy script in package.json
"scripts": { "deploy": "gh-pages -d dist" }
-
edit vite.config.js
export default defineConfig({ base: '/repository-name/', })
-
config github page
set branch to
gh-pages
-
deploy
npm run build npm run deploy
-
visit
https://username.github.io/repository-name/
-
custom domain
if you want to use custom domain like readom.maxyoun.fun,
you need to set custom domain in github page setting.
and the base of vite.config.js should be /
github page with jekyll
-
github创建仓库
参照https://pages.github.com/
-
jekyll
https://jekyllrb.com/docs/
需要注意的是, 在已有仓库里初始化jekyll, cd到仓库路径下, 运行
$ jekyll new . --force
在本地运行
bundle exec jekyll server
在浏览器访问
localhost:4000
就可以看到效果了 -
jekyll theme
上一步看到的是默认模板, 可以采用网上的模板来美化我们的博客
我采用的是https://github.com/willard-yuan/willard-yuan.github.io
按照步骤做就可以了
Docsify部署markdown文档
Docsify部署markdown文档
优化
- C++ code color
在index.html里引用js:<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-c.js"></script> <script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-cpp.js"></script>
markdown文件里写C++代码时加上cpp标签
- latex
add Katex css to the header of index.html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
add js to the body of index.html
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script>
config the latex
<script> window.$docsify = { plugins: [ function (hook) { hook.doneEach(function () { renderMathInElement(document.body, { delimiters: [ { left: "$$", right: "$$", display: true }, { left: "$", right: "$", display: false }, { left: "\\(", right: "\\)", display: false }, { left: "\\[", right: "\\]", display: true } ] }); }); } ] }; </script>
write latex in markdown file like this:
Here is an inline equation: $E = mc^2$. And here is a block equation: $$ \int_{a}^{b} f(x) \, dx $$
Material for MkDocs部署markdown文档
Material for MkDocs部署markdown文档