原文链接:优雅的使用Webstack打造个人网址导航
一款基于 WebStackPage 的 Hexo 主题。本人选择的是 hexo-theme-webstack。
具体效果请移步 个人网址导航。
hexo init
初始化项目。hexo init Nav_Tzy(项目名)
Nav_Tzy
,输入npm i
安装相关依赖。cd Nav_Tzy //进入Nav_Tzy文件夹
npm i
执行完命令之后,文件目录大概如下图:
【node_modules】:依赖包
【scaffolds】:生成文章的一些模板
【source】:用来存放你的文章
【themes】:主题
【.npmignore】:发布时忽略的文件(可忽略)
【_config.landscape.yml】:主题的配置文件
【_config.yml】:博客的配置文件
【package.json】:项目名称、描述、版本、运行和开发等信息
3. 安装主题
# hexo >= 4.0
git clone https://github.com/HCLonely/hexo-theme-webstack themes/webstack
# hexo >= 5.0
npm install hexo-theme-webstack -S
_config.yml
,把主题改为webstack
,注意这里初始值是landscape
。theme: webstack
将根目录下_config.landscape.yml
改名为_config.webstack.yml
。
将【D:/studytype/My_Blog/Nav_Tzy/node_modules/hexo-theme-webstack】下的_config.example.yml
中的内容复制到根目录下的_config.webstack.yml
。
5. 编译运行
hexo g && hexo s
打开浏览器,输入地址:http://localhost:4000/,即可看到如下效果:
favicon: /favicon.ico
banner: /images/webstack_banner_cn.png
logo:expanded: /images/logo@2x.pngcollapsed: /images/logo-collapsed@2x.pngdark: /images/logo_dark@2x.png
语言标识。
flag:- name: Chinesedefault: trueicon: flag-cnindex: /index.html
是否显示搜索框。
search: true
自定义搜索引擎。
userDefinedSearchData:custom: truethisSearch: https://www.baidu.com/s?wd=thisSearchIcon: url(https://www.baidu.com/favicon.ico)hotStatus: truedata:- name: 百度img: url(https://www.baidu.com/favicon.ico)url: https://www.baidu.com/s?wd=- name: 谷歌img: url(https://www.google.com/favicon.ico)url: https://www.google.com/search?q=
右上角的 github corner , 将 href 的属性改为自己的 github 地址即可。
githubCorner: ''
建站年份,显示在页面底部。
since: 2020
侧边栏菜单设置。
config
, 此选项内容包含name
, icon
, config
选项menu:- name: 常用工具icon: far fa-starconfig: hotTools- name: 其他工具icon: fas fa-toolssubmenu:- name: 开发工具icon: fas fa-toolsconfig: devTools- name: 我的博客icon: fas fa-blogconfig: myBlog
是否将侧边栏全部展开。
expandAll: true
侧边栏的关于本站。
about:url: /about/icon: far fa-heartname: 关于本站
不蒜子统计。
busuanzi:enable: trueposition: sidebarpv: 本站总访问量$pvuv: 本站总访客数$uv
网站内容设置。
- name: Ethan.Tzyurl: https://tzy1997.com/img: https://bu.dusays.com/2022/05/17/6283c38e6368f.icodescription: 不忘初心,方得始终。
在menu
和submenu
中设置的config
的内容为此选项的名称。
例menu
:
menu:- name: 常用工具icon: far fa-starconfig: hotTools
则常用工具
分组里的网站有以下两种添加方式:
hotTools:- name: Ethan.Tzyurl: https://tzy1997.com/img: https://bu.dusays.com/2022/05/17/6283c38e6368f.icodescription: 不忘初心,方得始终。- name: Githuburl: https://github.com/img: /images/logos/github.pngdescription: 面向开源及私有软件项目的托管平台。
- name: Ethan.Tzyurl: https://tzy1997.com/img: https://bu.dusays.com/2022/05/17/6283c38e6368f.icodescription: 不忘初心,方得始终。
- name: Githuburl: https://github.com/img: /images/logos/github.pngdescription: 面向开源及私有软件项目的托管平台。
以上两种方式任选一种即可,建议使用第二种。
这里只写了部分配置,更多详细配置 请参考 hexo-theme-webstack 。
如果你了解过【Hexo + Butterfly】的搭建流程,想必【Hexo + Webstack】对于你来说也不会太难。
你可以将编译出来的文件夹【D:/studytype/My_Blog/Nav_Tzy/public】丢进你的服务器目录。也可以部署到 Github 上,方法同【Hexo + Butterfly】一样。
例如,我的个人站的地址是【tzy1997.com】,个人导航站的地址【nav.tzy1997.com】,我只需将【个人导航站】以外链的形式嵌入【个人站】即可。
如果你没有服务器,没有多余的 Github(不想那么麻烦的话),可以使用下面本站所使用的方法:
将编译出来的【D:/studytype/My_Blog/Nav_Tzy/public/index.html】直接丢进【Hexo + Butterfly】项目中。然后跳过 Hexo 的编译即可。
在这里需要将【index.html】重新命名(xxx.html),避免与【Hexo + Butterfly】项目的根页面冲突。
将【xxx.html】文件丢进【BlogRoot/soruce】文件夹中,然后在站点配置文件【BlogRoot/_config.yml】,修改skip_render
属性即可。
skip_render: ['xxx.html'] # 跳过多个目录,或者多个文件
最后在【Hexo + Butterfly】主题配置文件中的menu
将页面嵌入即可。例如:
首页: / || fas fa-home其他||fa-fw fas fa-coffee:需求墙: /demandWall/ || fa fa-bug网址收藏: https://tzy1997.com/nav.html || fa-fw fas fa-infinity
到此,你学废了吗?
有问题记得及时留言!