• 个人博客搭建记录(不用CSDN了)


    个人博客地址:www.jiasun.top

    使用github page+hexo搭建,主题为fluid,搭建步骤参照:Github + hexo 实现自己的个人博客、配置主题(超详细)

    主题:https://hexo.fluid-dev.com/

    搭建时的问题:
    1 Ubuntu apt默认下载的nodejs版本过低,snap安装18.18的node js
    2 在source目录下添加CNAME文件指定个人域名
    3 在iconfont中搜索所需图标,并通过自定义css导入项目 自定义图标
    4 在source目录下添加本地图片以便博客引用
    5 通过CsdnSyncHexo将csdn博客导出为markdown格式并移至source/_posts目录下
    6 csdn博客迁移后图片显示403, 只需要在每个文章的头部加上这么一句代码就可以

    在这里插入图片描述
    Hexo 搭建:图片不能正常显示问题(简书图片403)

    该语句能生效的原因:
    http请求头中有一个referrer字段,用来表示发起http请求的源地址信息
    服务器端在拿到这个referrer值后判断请求是否来自本站
    若不是则返回403,从而实现图片的防盗链。上面出现403就是因为,请求的是别人服务器上的资源,但把自己的referrer信息带过去了,被对方服务器拦截返回了403
    在前端可以通过meta来设置referrer policy(来源策略),referrer设置成no-referrer,发送请求不会带上referrer信息,对方服务器也就无法拦截了

    get请求图片出现403 防盗链解决方式 no-referrer

    通过vscode替换功能一次性更新所有博客md文件

    ---
    
    <!--more-->
    
    # 换成
    
    ---
    <meta name="referrer" content="no-referrer" />
    <!--more-->
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    7 csdn导出的markdown文件toc目录未能正常显示,文章开头没有以下类似的东西,只显示一个TOC字符
    在这里插入图片描述
    但发现侧边栏也有目录,故删去TOC语句
    在这里插入图片描述
    通过vscode正则匹配一次性删去所有TOC行

    ^.*(@[TOC]).*\n
    
    • 1

    VSCode 批量删除指定匹配的一整行

    8 导出的markdown文件分类以空格分割,需手动改成-[]分割

    categories: 踩坑日记 源码剖析 内核驱动开发记录
    
    # 改成
    
    categories: 
    - [踩坑日记]
    - [源码剖析]
    - [内核驱动开发记录]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    分类和标签

    9 代码风格改成atom-one-dark

        highlightjs:
          # 在链接中挑选 style 填入
          # Select a style in the link
          # See: https://highlightjs.org/static/demo/
          style: "atom-one-dark"
          style_dark: "atom-one-dark"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    https://highlightjs.org/demo
    好像要npm install highlightjs --save

    10 添加音乐播放器
    在网易云得到外链

    <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=65800&auto=1&height=66"></iframe>
    
    • 1

    在node_modules/hexo-theme-fluid/layout/about.ejs中加入

    <div class="music-player">
      <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=65800&auto=1&height=66"></iframe>
    </div>
    
    • 1
    • 2
    • 3

    可以通过修改node_modules/hexo-theme-fluid/修改页面信息
    最终效果:
    在这里插入图片描述
    hexo 第四讲 – 界面中加入音乐

    11 增加评论功能
    主要依据以下这篇博客,注册leancloud账号,将AppID AppKey serverURLs填入valine配置中,不过这博客有点误导人,以为serverURLs是填安全域名呢,实际上应该填REST API 服务器地址
    hexo-fluid添加valine评论记录

    效果:
    在这里插入图片描述

    12 增加访问数统计
    主要依据Hexo-fluid主题设置统计博客阅读量同样在leancloud创建应用,得到AppID AppKey serverURLs,而后修改主题配置,注意填入serverURLs。但这篇博客只使能了博客阅读次数统计,实际上还有总访问次数统计
    在这里插入图片描述
    最终效果:
    在这里插入图片描述
    在这里插入图片描述

    13 将网站加入各个搜索引擎
    参考博客:
    hexo博客的高级SEO优化【灰鸿】
    如何在Google Search Console里设置网站域名的DNS验证

    将网站加入百度,必应,谷歌3个网站,添加sitemap站点地图,优化URL,代码压缩

    百度加入网站步骤一大堆,烦死了,真恶心

    14 自动摘要
    在这里插入图片描述
    csdn导出的markdown文件都有一行,妨碍了生成自动摘要,全部删除

    15 博客封面未能成功显示,返回403,
    在node_modules/hexo-theme-fluid/layout/index.ejs文件中加入no-referrer语句 (与加入音乐播放器类似的思路)
    在这里插入图片描述

    在这里插入图片描述

    目录结构
    在这里插入图片描述

  • 相关阅读:
    软件工程与计算总结(二十三)软件工程职业基础
    Python 快速入门
    【七夕特别篇】七夕已至,让爱闪耀
    如何快速同步第三方平台数据?
    MySQL 允许SQL最大长度
    java 线程池
    xdma axi-stream
    接口、interface关键字
    两个星期学会软件测试?我震惊了!
    pip install torch
  • 原文地址:https://blog.csdn.net/freedom1523646952/article/details/133158787