十分钟入门Github Page
hexo Start 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 npm -v cd wumin199.github.io/npm install cd wumin199.github.io/npm install -g hexo-cli hexo -v npm install hexo-cli npx hexo -v
说明:
在windows下按照nodejs,如果不是安卓在C盘下,执行 npm -v
的时候会报错:
1 2 3 4 5 6 7 8 PS C:\Users\wumin> npm -v npm : 无法加载文件 D:\installed\nodejs\npm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.co m/fwlink/?LinkID=135170 中的 about_Execution_Policies。 所在位置 行:1 字符: 1 + npm -v + ~~~ + CategoryInfo : SecurityError: (:) [],PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
解决方法是在powershell中执行: Set-ExecutionPolicy Bypass -Scope Process -Force
不过后续也会有其他问题,比如 npm install 会安装到其他目录中,而不是项目文件夹下
Windows下可以通过程序与管理,卸载Nodejs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 hexo clean hexo g hexo s hexo new "my_new_pose" git add . git commit -am "" git push
有时候需要切换端口
1 2 3 hexo server -p 5612 hexo s -p 5612
有时候打不开网页,可以尝试如下方法:
切换到Edge浏览器或者Firefox浏览器
https://localhost:5612/
-> http://localhost:5612/
Page说明
图片是放到 wm-blog-image
这个repo的main分支下
选择Hexo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - && sudo apt-get install -y nodejs node -v npm -v apt-get purge nodejs && rm -r /etc/apt/sources.list.d/nodesource.list npm install -g hexo-cli echo 'PATH="$PATH:/usr/lib/node_modules/hexo-cli/node_modules/.bin"' >> ~/.profilesource ~/.profile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 mkdir websitecd websitehexo init [folder] cd website/themesmkdir icaruscd icarusgit clone https://github.com/ppoffice/hexo-theme-icarus.git --depth 1 cd website npm install -S hexo-theme-icarus hexo-renderer-inferno npm install --save hexo-blog-encrypt updatedb npm list _config.yml -> theme: icarus hexo new "post title" hexo new page --path about/me "About me" hexo g hexo server cd websitegit init git add . git commit -am "update" git remote add origin git@github.com:wumin199/wumin199.github.io.git git branch -M main git push -u origin main git add . git commit -am "" hexo g hexo s git push
自动部署: .github/workflows/pages.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 name: Pages on: push: branches: - main jobs: pages: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v2 - name: Use Node.js 18. x uses: actions/setup-node@v2 with: node-version: "18" - name: Cache NPM dependencies uses: actions/cache@v2 with: path: node_modules key: ${{ runner.OS }}-npm-cache restore-keys: | ${{ runner.OS }}-npm-cache - name: Install Dependencies run: npm install - name: Build run: npm run build - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public
参考资料