四十五、Gtihub+Hexo+icarus搭建自己的博客
发布日期:2021-07-01 02:07:45 浏览次数:2 分类:技术文章

本文共 12395 字,大约阅读时间需要 41 分钟。

最近我看了hexo的主题,发现了很多好看的主题。很多人的博客就是用别人的主题,搞出来的。之前我的博客发现真的是太难看了,然后没有去维护。那个时候不知道没有关系,今天我知道了,就是把之前删除了。

我在茫茫的主题中发现了它,这个就是大神开发的:https://shen-yu.gitee.io/

对应的Github:https://github.com/Shen-Yu/hexo-theme-ayer

我先去给大神Star了,这个大神牛逼。百度发现教程不足,搭建起来头疼。遇到问题,Github上又没有解释。

最后决定用icarus,好像很多人用这个主题

文章目录

开干

在本地创建一个博客目录

hexo init blog

上面这个命令执行完后,会在本地创建一个 blog 目录,然后进入到这个目录中,执行 npm install 命令,安装相关的依赖。

现在去_config.yml文件中,做网站的一些基本配置, 网站的 title,描述,关键字、图标等,这些配置搞定。如下

# Sitetitle: 'Python之王'subtitle: 'Python之王'description: '人生最重要的不是所站的位置,而是内心所朝的方向。只要我在每篇博文中写得自己体会,修炼身心;在每天的不断重复学习中,耐住寂寞,练就真功,不畏艰难,奋勇前行,不忘初心,砥砺前行,人生定会有所收获,不留遗憾...'keywords: 'Python, Java, 机器学习, 爬虫, 前端, Spring家族, 人工智能'author: 'Runsen'language: entimezone: ''

配置完成后,定位到 blog 目录,执行hexo s就可以在本地启动项目了,浏览器中输入 http://localhost:4000 就可以看到网站了,就是那个最难看的页面。

补充下hexo的命令

新建GIthub项目,创建 {username}.GIthub.io 的仓库,

修改主题

Hexo 默认使用的主题是 landscape ,之前使用了 hexo-theme-next 主题,现在我用melody 。

下面就是看官方教程来搞下来。

首先将之克隆到 ./themes 目录下,这个目录下原本有有一个 landscape 文件夹,里边放的默认的样式,

首先命令行进入到项目的根目录,执行如下命令即可:

git clone  https://github.com/Molunerfinn/hexo-theme-melody themes/melody

克隆成功后,修改 hexo 的 _config.yml 文件,将主题修改为 melody,如下:

theme: icarus

这个时候就可以跑起来了。

配置主题

主题创建好之后,接下来就是对主题的配置了,这个比较麻烦,直接参考官方文档和Github教程即可。

下面是我的主题配置

# Version of the configuration fileversion: 3.0.0# Icarus theme variant, can be "default" or "cyberpunk"variant: default# Path or URL to the website's logologo: /img/logo.png# Page metadata configurationshead:    # URL or path to the website's icon    favicon: /img/avatar.png    # Open Graph metadata    # https://hexo.io/docs/helpers.html#open-graph    open_graph:        # Page title (og:title) (optional)        # You should leave this blank for most of the time        title:         # Page type (og:type) (optional)        # You should leave this blank for most of the time        type: blog        # Page URL (og:url) (optional)        # You should leave this blank for most of the time        url:         # Page cover (og:image) (optional)        # You should leave this blank for most of the time        image:         # Site name (og:site_name) (optional)        # You should leave this blank for most of the time        site_name:         # Page author (article:author) (optional)        # You should leave this blank for most of the time        author:         # Page description (og:description) (optional)        # You should leave this blank for most of the time        description:         # Twitter card type (twitter:card)        twitter_card:         # Twitter ID (twitter:creator)        twitter_id:         # Twitter Site (twitter:site)        twitter_site:         # Google+ profile link (deprecated)        google_plus:         # Facebook admin ID        fb_admins:         # Facebook App ID        fb_app_id:     # Structured data of the page    # https://developers.google.com/search/docs/guides/intro-structured-data    structured_data:        # Page title (optional)        # You should leave this blank for most of the time        title:         # Page description (optional)        # You should leave this blank for most of the time        description:         # Page URL (optional)        # You should leave this blank for most of the time        url:         # Page author (article:author) (optional)        # You should leave this blank for most of the time        author:         # Page images (optional)        # You should leave this blank for most of the time        image:     # Additional HTML meta tags in an array    meta:        # Meta tag specified in 
=
style # E.g., name=theme-color;content=#123456 =>
- 'name=theme-color;content=#123456' - 'name=generator;content="Hexo 4.2.0"' # URL or path to the website's RSS atom.xml rss: /path/to/atom.xml navbar: # Navigation bar menu links menu: #菜单显示改为中文 首页: / 归档: /archives 分类: /categories 标签: /tags 关于: /about # Links to be shown on the right of the navigation bar links: Download on GitHub: icon: fab fa-github url: 'https://github.com/ppoffice/hexo-theme-icarus'# Page footer configurationsfooter: # Links to be shown on the right of the footer section links: Creative Commons: icon: fab fa-creative-commons url: 'https://creativecommons.org/' Attribution 4.0 International: icon: fab fa-creative-commons-by url: 'https://creativecommons.org/licenses/by/4.0/' Download on GitHub: icon: fab fa-github url: 'https://github.com/ppoffice/hexo-theme-icarus'# Article related configurationsarticle: # Code highlight settings highlight: # Code highlight themes # https://github.com/highlightjs/highlight.js/tree/master/src/styles theme: atom-one-light # Show copy code button clipboard: true # Default folding status of the code blocks. Can be "", "folded", "unfolded" fold: unfolded # Whether to show thumbnail image for every article thumbnail: true # Whether to show estimated article reading time readtime: true# Search plugin configurations# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Search/search: type: insight# Comment plugin configurations# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Comment/comment: type: disqus # Disqus shortname shortname: 'Runsen' avatar: retro # Gravatar style : mm/identicon/monsterid/wavatar/retro/hide placeholder: 要不要说点啥... # Comment Box placeholder# Donate plugin configurations# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Donation/donates: # Alipay donate button configurations - type: alipay # Alipay qrcode image URL qrcode: '/img/alipay.png' # "Buy me a coffee" donate button configurations # Wechat donate button configurations - type: wechat # Wechat qrcode image URL qrcode: '/img/wechat.png'# Share plugin configurations# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Share/share: type: sharejs # URL to the ShareThis share plugin script install_url: ''# Sidebar configurations.# Please be noted that a sidebar is only visible when it has at least one widgetsidebar: # Left sidebar configurations left: # Whether the sidebar sticks to the top when page scrolls sticky: true # Right sidebar configurations right: # Whether the sidebar sticks to the top when page scrolls sticky: true # Sidebar widget configurations# http://ppoffice.github.io/hexo-theme-icarus/categories/Widgets/widgets: - # Where should the widget be placed, left sidebar or right sidebar type: toc position: right # Profile widget configurations - # Where should the widget be placed, left sidebar or right sidebar position: left type: profile # Author name author: Runsen # Author title author_title: 喜欢折腾的Runsen,微信联系:RunsenLiu # Author's current location location: 中国广东某一个辣鸡学院 # URL or path to the avatar image avatar: # Whether show the rounded avatar image avatar_rounded: false # Email address for the Gravatar gravatar: # URL or path for the follow button follow_link: 'https://github.com/MaoliRUNsen' # Links to be shown on the bottom of the profile widget social_links: Github: icon: fab fa-github url: 'https://github.com/MaoliRUNsen' QQ: icon: fab fa-qq url: 'http://wpa.qq.com/msgrd?v=1&uin=2953510364&site=ioshenmue&menu=yes' RSS: icon: fas fa-rss url: / # Table of contents widget configurations # Recommendation links widget configurations - # Where should the widget be placed, left sidebar or right sidebar position: left type: links # Names and URLs of the sites links: CSDN: 'https://blog.csdn.net/weixin_44510615' 知乎: 'https://www.zhihu.com/people/qian-xiao-28-8' 头条: 'https://www.toutiao.com/c/user/2115112815048734/' # Categories widget configurations - # Where should the widget be placed, left sidebar or right sidebar position: left type: categories # Recent posts widget configurations - # Where should the widget be placed, left sidebar or right sidebar position: right type: recent_posts # Archives widget configurations - # Where should the widget be placed, left sidebar or right sidebar position: left type: archives # Tags widget configurations - # Where should the widget be placed, left sidebar or right sidebar position: right type: tags# https://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/speed-up-your-site-with-custom-cdn/providers: # Name or URL template of the JavaScript and/or stylesheet CDN provider cdn: jsdelivr # Name or URL template of the webfont CDN provider fontcdn: google # Name or URL of the fontawesome icon font CDN provider iconcdn: fontawesome

项目配置

下面是项目的根目录配置

# Hexo Configuration## Docs: https://hexo.io/docs/configuration.html## Source: https://github.com/hexojs/hexo/# Sitetitle: 'Python之王'subtitle: 'Python之王'description: '人生最重要的不是所站的位置,而是内心所朝的方向。只要我在每篇博文中写得自己体会,修炼身心;在每天的不断重复学习中,耐住寂寞,练就真功,不畏艰难,奋勇前行,不忘初心,砥砺前行,人生定会有所收获,不留遗憾...'keywords: 'Python, Java, 机器学习, 爬虫, 前端, Spring家族, 人工智能'author: 'Runsen'language: zh-CNtimezone: 'Asia/Shanghai'# URL## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'url: https://maolirunsen.github.io/root: /permalink: :year/:month/:day/:title/permalink_defaults:pretty_urls:  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks  trailing_html: true # Set to false to remove trailing '.html' from permalinkssearch:  path: search.xml  field: post# Directorysource_dir: sourcepublic_dir: publictag_dir: tagsarchive_dir: archivescategory_dir: categoriescode_dir: downloads/codei18n_dir: :langskip_render:# Writingnew_post_name: :title.md # File name of new postsdefault_layout: posttitlecase: false # Transform title into titlecaseexternal_link:  enable: true # Open external links in new tab  field: site # Apply to the whole site  exclude: 'default_category'filename_case: 0render_drafts: truepost_asset_folder: truerelative_link: truefuture: truehighlight:  enable: true  line_number: true  auto_detect: true  tab_replace: ''  wrap: true  hljs: true# Home page setting# path: Root path for your blogs index page. (default = '')# per_page: Posts displayed per page. (0 = disable pagination)# order_by: Posts order. (Order by date descending by default)index_generator:  path: ''  per_page: 10  order_by: -date# Category & Tagdefault_category: uncategorizedcategory_map:tag_map:# Metadata elements## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/metameta_generator: true# Date / Time format## Hexo uses Moment.js to parse and display date## You can customize the date format as defined in## http://momentjs.com/docs/#/displaying/format/date_format: YYYY-MM-DDtime_format: HH:mm:ss## Use post's date for updated date unless set in front-matteruse_date_for_updated: true# Pagination## Set per_page to 0 to disable paginationper_page: 10pagination_dir: page# Include / Exclude file(s)## include:/exclude: options only apply to the 'source/' folder# include:# exclude:# ignore:#busuanzi:#  enable: true# ---------------下面选项需要对应插件的支持---------------# npm install hexo-generator-index --save# npm install hexo-generator-archive --save# npm install hexo-generator-category --save# npm install hexo-generator-tag --savearchive_generator:  per_page: 20 ##归档页面默认20篇文章标题  yearly: true  ##生成年视图  monthly: true ##生成月视图tag_generator:  per_page: 10 ##标签分类页面默认10篇文章category_generator:  per_page: 10 ###分类页面默认10篇文章# Extensions## Plugins: https://hexo.io/plugins/## Themes: https://hexo.io/themes/theme: icarus# 多说 ShortNamebusuanzi:  enable: true# Deployment## Docs: https://hexo.io/docs/deployment.htmldeploy:  type: git  repo: https://github.com/MaoliRUNsen/MaoliRUNsen.github.io.git  branch: master

写文章

写文章时需要有下面的标志,没有<!-- more -->就不能有阅读全文的标签。

`

---tags: - Python环境categories:- Pythontoc: true---
1、 搭建Python的基础环境

下面就是搭建的效果。

https://maolirunsen.github.io/

有个问题就是不知道怎么解析域名,卡了好久了。还有,网站访问比较慢。

转载地址:https://maoli.blog.csdn.net/article/details/107426648 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:四十六、微信小程序快速开发入门
下一篇:四十三、在Vue使用router,路由的管理

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月13日 01时04分55秒