From 54117504ead83e151a0b1637acbda633780c5a5c Mon Sep 17 00:00:00 2001 From: xugaoyi <894072666@qq.com> Date: Tue, 17 Dec 2019 17:04:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20and=20add=20=E7=99=BE?= =?UTF-8?q?=E5=BA=A6=E6=94=B6=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- README.MD | 13 +----- deploy.sh | 2 +- docs/.vuepress/config/nav.js | 2 + docs/.vuepress/config/sidebar.js | 2 + docs/other/baidushoulu.md | 69 ++++++++++++++++++++++++-------- docs/readme.md | 4 +- 7 files changed, 62 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b58a887..0710da0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,5 +29,5 @@ jobs: # 工作流 BASE_BRANCH: master # 要部署的文件夹所在的分支. BRANCH: gh-pages # 部署到的分支 FOLDER: docs/.vuepress/dist # 要部署的文件夹. - BUILD_SCRIPT: npm install && npm run build && cd docs/.vuepress/dist && echo 'b.evanblogweb.com' > CNAME && cd - # 部署前要执行的命令 + BUILD_SCRIPT: npm install && npm run build && cd docs/.vuepress/dist && echo 'b.evanblogweb.com' > CNAME && cd - # 部署前要执行的命令,记得进入某个目录后要后面要退回开始的目录 # \ No newline at end of file diff --git a/README.MD b/README.MD index 04b4c54..45c987b 100644 --- a/README.MD +++ b/README.MD @@ -76,7 +76,7 @@ npm run deploy # 运行部署脚本deploy.sh,并发布到仓库的gh-pages分支 > 注意:如果您有自定义域名,需要在`.github/workflows/ci.yml`中修改`evanblogweb.com`为你的域名。 > -> 如没有自定义域名,需要在`.github/workflows/ci.yml`中去掉`cd docs/.vuepress/dist && echo 'evanblogweb.com' > CNAME`命令 +> 如没有自定义域名,需要在`.github/workflows/ci.yml`中去掉`cd docs/.vuepress/dist && echo 'evanblogweb.com' > CNAME && cd -`命令 @@ -115,7 +115,7 @@ echo 'evanblogweb.com' > CNAME # // 域名替换成你的 在自动部署配置文件ci.yml的jobs.build.steps..env.BUILD_SCRIPT中添加脚本 ```sh -"cd docs/.vuepress/dist && echo 'evanblogweb.com' > CNAME" +"cd docs/.vuepress/dist && echo 'evanblogweb.com' > CNAME" && cd - # 域名替换成你的 ``` @@ -129,15 +129,6 @@ echo 'evanblogweb.com' > CNAME # // 域名替换成你的 必须放在 md 文件在最上方才能生效 - -#### 想要自动发现新 md 文件并加入侧边栏索引列表?(待修改) - -博客的最基本功能,需要加一点 node 的脚本来更新 sidebar:[]的配置。放在了 utils/getFilenames.js 了。 -脚本运行时会查找/web/等 3 个文件夹下的所有目录和文件,将名称列表置入.vuepress/config/sidebar.json。 -之后重新 npm run list,列表更新 - - - #### 百度自动推送和统计 加入了自动推送和统计插件 diff --git a/deploy.sh b/deploy.sh index bcd7822..3746fd5 100644 --- a/deploy.sh +++ b/deploy.sh @@ -32,5 +32,5 @@ git commit -m 'deploy' git push -f git@git.dev.tencent.com:xugaoyi/xugaoyi.git master # 发布到coding.net -cd - +cd - # 退回开始所在目录 rm -rf docs/.vuepress/dist \ No newline at end of file diff --git a/docs/.vuepress/config/nav.js b/docs/.vuepress/config/nav.js index 09c10ca..ed2925b 100644 --- a/docs/.vuepress/config/nav.js +++ b/docs/.vuepress/config/nav.js @@ -29,6 +29,7 @@ module.exports = [ ]}, {text: '学习笔记',items:[ {text: '小程序笔记',link: '/other/note/01.小程序笔记'}, + {text: '《Python语言程序设计》基础课程学习',link: 'https://github.com/xugaoyi/python-learn'}, ]}, {text: '面试',items:[ {text: '面试问答集锦', link: '/other/interview'}, @@ -36,6 +37,7 @@ module.exports = [ {text: '其他',items:[ {text: '在线工具', link: '/other/utils'}, {text: '关于本博客搭建', link: 'https://github.com/xugaoyi/evanblog'}, + {text: '解决百度无法收录搭建在GitHub上的个人博客的问题', link: '/other/baidushoulu'} ]}, ]}, {text: '关于我',link: '/about/'} diff --git a/docs/.vuepress/config/sidebar.js b/docs/.vuepress/config/sidebar.js index 2b8b840..dc20da3 100644 --- a/docs/.vuepress/config/sidebar.js +++ b/docs/.vuepress/config/sidebar.js @@ -55,6 +55,7 @@ module.exports = { // 侧边栏 collapsable: false, children: [ ['note/01.小程序笔记','小程序笔记'], + ['https://github.com/xugaoyi/python-learn','《Python语言程序设计》基础课程学习'], ] }, { @@ -70,6 +71,7 @@ module.exports = { // 侧边栏 children: [ ['utils','在线工具'], ['https://github.com/xugaoyi/evanblog','关于本博客搭建'], + ['baidushoulu','解决百度无法收录搭建在GitHub上的个人博客的问题'] ] }, ], diff --git a/docs/other/baidushoulu.md b/docs/other/baidushoulu.md index 598d3e5..a4710e2 100644 --- a/docs/other/baidushoulu.md +++ b/docs/other/baidushoulu.md @@ -1,34 +1,69 @@ -# 解决百度爬虫无法爬取搭建在GitHub上的个人博客的问题 +# 解决百度无法收录搭建在GitHub上的个人博客的问题 ## 背景 -由于GitHub禁止百度爬虫访问,造成托管在GitHub Pages上的博客无法被百度收录。相关问题可以通过百度站长平台的抓取诊断再现,每次都是403 Forbidden的错误… +由于GitHub禁止百度爬虫访问,造成托管在GitHub Pages上的博客无法被百度收录。相关问题可以通过百度站长平台的`抓取诊断`再现,每次都是403 Forbidden的错误。 ## 解决方案 -将博客同时同步托管到GitHub Pages和[coding.net](https://coding.net/)上,解决百度不收录问题。 +同时将博客同时同步托管到GitHub Pages和[coding pages](https://dev.tencent.com/)上,解决百度不收录问题。最后发现在国内使用coding pages打开速度特别快,而且还会被百度收录,因此我把coding pages的站点作为主站点,原本在github pages的作为分站点。 + +> 注意:我使用的是coding个人版,即腾讯云开发者平台。 步骤: -1、注册[coding.net](https://coding.net/)账号 +1、注册[coding](https://dev.tencent.com/)账号,创建仓库,把代码推送到coding仓库,并开启pages服务。 -2、创建一个跟账号用户名同名的仓库,例如:https://e.coding.net/username/username.git +> git 操作部分和使用github的差不多,不了解git操作的可以看我的另一篇文章:[Git使用文档](./git.md) -3、配置 SSH 公钥,配置方法请查看[帮助](https://help.coding.net/docs/project/features/ssh.html) +2、我的博客项目使用vuepress搭建的,使用的是如下自动部署脚本,同时将代码推送到github和conding。 -4、在终端下进入本地博客目录evanblog(假设目录名为evanblog),添加coding.net的远程地址,新建分支,提交代码到coding.net +```sh +#!/usr/bin/env sh -```bash -cd evanblog -git remote add coding https://e.coding.net/username/username.git # 关联远程仓库 -git checkout -b coding-pages -git checkout master -git branch -> coding-pages -> * master -git push coding master/coding-pages # 提交代码到远程仓库的指定分支 +# 确保脚本抛出遇到的错误 +set -e + +# 生成静态文件 +npm run build + +# 进入生成的文件夹 +cd docs/.vuepress/dist + +# github +echo 'b.evanblogweb.com' > CNAME +git init +git add -A +git commit -m 'deploy' +git push -f git@github.com:xugaoyi/evanblog.git master:gh-pages # 发布到github + +# coding +echo 'evanblogweb.com' > CNAME +git add -A +git commit -m 'deploy' +git push -f git@git.dev.tencent.com:xugaoyi/xugaoyi.git master # 发布到coding + +cd - # 退回开始所在目录 +rm -rf docs/.vuepress/dist +``` + +> 因为我想给两个平台上绑定不同的自定义域名,因此我分开创建了CNAME文件。 + +3、有自定义域名的,也可以在coding pages绑定自定义域名,域名DNS解析中添加CNAME记录指向coding pages的站点地址即可。(没有自定义域名的可忽略,同时把自动部署脚本中的创建CNAME文件的脚本去掉) + + + +最后,使用百度站长的抓取诊断,发现抓取成功啦,再使用百度站长的[链接提交](https://ziyuan.baidu.com/linksubmit/index)功能,把链接提交给百度,过一段时间就可能在百度搜索中搜索到啦。 + + + +### 如何知道百度有没有收录? + +在百度搜索框中使用site:<链接地址\>,如: + +``` +site:evanblogweb.com ``` -> 关于git操作可查阅:[Git使用文档](./git.md) \ No newline at end of file diff --git a/docs/readme.md b/docs/readme.md index 404ba2b..564d69e 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -46,13 +46,13 @@ footer: Copyright © 2019-present evanblog * [更多... 👉](other/git) * 学习 * [学习效果低,忘性很大怎么办?](other/LearningAndMemory) - * [学习网站分享](other/study) - * [更多... 👉](other/LearningAndMemory) + * [学习网站分享](other/study) * 面试 * [面试问题集锦](other/interview) * 其他 * [在线工具](other/utils) * [关于本博客搭建](https://github.com/xugaoyi/evanblog) + * [解决百度无法收录搭建在GitHub上的个人博客的问题](other/baidushoulu) ## :email: 联系