# URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' ## 如果您的网站存放在子目录中,例如 http://yoursite.com/blog,则请将您的 url 设为 http://yoursite.com/blog 并把 root 设为 /blog/ url: http://tianyu-code.top # 网址 root: / # 网站根目录 permalink: :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 permalinks
# When running the site in a subdirectory (e.g. domain.tld/blog), remove the leading slash from link value (/archives -> archives). # Usage: `Key: /link/ || icon` # Key is the name of menu item. If translate for this menu will find in languages - this translate will be loaded; if not - Key name will be used. Key is case-senstive. # Value before `||` delimeter is the target link. # Value after `||` delimeter is the name of FontAwesome icon. If icon (with or without delimeter) is not specified, question icon will be loaded. menu: home: /|| home #about: /about/ || user tags: /tags/|| tags categories: /categories/|| th #archives: /archives/ || archive #schedule: /schedule/ || calendar #sitemap: /sitemap.xml || sitemap #commonweal: /404/ || heartbeat
# Enable/Disable menu icons. menu_icons: enable: true
我在配置时必须把跳转路径后面的空格去掉,不然在跳转的时候空格也会在路径中导致失败
新增分类/标签等目录
在完成上述配置后,我们指定了按钮的跳转路径,但是这个目录还未存在,需要手动创建,在博客目录输入hexo new page categories,即可创建分类目录,会在source下面生成categories目录,里面的index.md即为categories界面的显示文件,index.md文件修改如下:
# Social Links. # Usage: `Key: permalink || icon` # Key is the link label showing to end users. # Value before `||` delimeter is the target permalink. # Value after `||` delimeter is the name of FontAwesome icon. If icon (with or without delimeter) is not specified, globe icon will be loaded. social: GitHub: https://github.com/tianyu-code || github E-Mail: mailto:1406985325@qq.com || envelope #Google: https://plus.google.com/yourname || google #Twitter: https://twitter.com/yourname || twitter #FB Page: https://www.facebook.com/yourname || facebook #VK Group: https://vk.com/yourname || vk #StackOverflow: https://stackoverflow.com/yourname || stack-overflow #YouTube: https://youtube.com/yourname || youtube #Instagram: https://instagram.com/yourname || instagram #Skype: skype:yourname?call|chat || skype
sidebar: # Sidebar Position, available value: left | right (only for Pisces | Gemini). position: left #position: right
# Sidebar Display, available value (only for Muse | Mist): # - post expand on posts automatically. Default. # - always expand for all pages automatically # - hide expand only when click on the sidebar toggle icon. # - remove Totally remove sidebar including sidebar toggle. display: post #display: always #display: hide #display: remove
# Sidebar offset from top menubar in pixels (only for Pisces | Gemini). 两个栏的间隔像素点 offset: 12
# Back to top in sidebar (only for Pisces | Gemini). 回到顶部按钮是否开启 b2t: true
# Scroll percent label in b2t button. 回到顶部按钮是否显示百分比 scrollpercent: true
# Enable sidebar on narrow view (only for Muse | Mist). onmobile: false
# --------------------------------------------------------------- # Post Settings # ---------------------------------------------------------------
# Automatically scroll page to section which is under <!-- more --> mark. # 自动滚动到<!--more-->下面 scroll_to_more: false
# Automatically saving scroll position on each post/page in cookies. # 使用cookies记录上次阅读位置 save_scroll: false
# Automatically excerpt description in homepage as preamble text. excerpt_description: true
# Automatically Excerpt. Not recommend. # Please use <!-- more --> in the post to control excerpt accurately. # 打开阅读更多按钮 auto_excerpt: enable: true length: 150
# Post meta display settings # 文章标题下面的一些元素,可选显示 post_meta: item_text: true created_at: true updated_at: true categories: true
效果如下:
文章版权声明
修改主题配置文件:
1 2 3 4 5 6
# Declare license on posts post_copyright: enable: true license: CC BY-NC-SA 3.0 license_url: https://creativecommons.org/licenses/by-nc-sa/3.0/
# Code Highlight theme # Available value: # normal | night | night eighties | night blue | night bright # https://github.com/chriskempson/tomorrow-theme highlight_theme: night eighties
footer: # Specify the date when the site was setup. # If not defined, current year will be used. since: 2020
# Icon between year and copyright info. icon: user
# If not defined, will be used `author` from Hexo main config. copyright: # ------------------------------------------------------------- # Hexo link (Powered by Hexo). powered: false
theme: # Theme & scheme info link (Theme - NexT.scheme). enable: false # Version info of NexT after scheme info (vX.X.X). version: false # ------------------------------------------------------------- # Any custom text can be defined here. #custom_text: Hosted by <a target="_blank" href="https://pages.github.com">GitHub Pages</a> custom_text: 田宇的个人博客
search: path: search.xml field: post format: html limit: 10000
主题配置文件修改如下:
1 2 3 4 5 6 7 8 9 10
# Local search # Dependencies: https://github.com/flashlab/hexo-generator-search local_search: enable: true # if auto, trigger search by changing input # if manual, trigger search by pressing enter key or search button trigger: auto # show top n results per article, show all results by setting to -1 top_n_per_article: 1
#! --------------------------------------------------------------- #! DO NOT EDIT THE FOLLOWING SETTINGS #! UNLESS YOU KNOW WHAT YOU ARE DOING #! ---------------------------------------------------------------
# Use velocity to animate everything. motion: enable: false async: false transition:
// Settings for some of the most global styles. // -------------------------------------------------- $body-bg-color = #eee $main-desktop = 90% //代表整体占用浏览器界面的百分比,即控制留白大小 $sidebar-desktop = 240px //侧边栏出现的位置 $content-desktop = calc(100% - 250px) //内容占用的大小
// Font size $font-size-base = 15px //字体大小 $font-size-base = unit(hexo-config('font.global.size'), px) if hexo-config('font.global.size') is a 'unit' $font-size-small = $font-size-base - 2px $font-size-smaller = $font-size-base - 4px $font-size-large = $font-size-base + 2px $font-size-larger = $font-size-base + 4px
使用不蒜子统计站点访问量
编辑主题配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Show PV/UV of the website/page with busuanzi. # Get more information on http://ibruce.info/2015/04/04/busuanzi/ busuanzi_count: # count values only if the other configs are false enable: true # custom uv span for the whole site site_uv: true site_uv_header: <i class="fa fa-user"></i>本站总访客数 site_uv_footer: 人次 # custom pv span for the whole site site_pv: true site_pv_header: <i class="fa fa-eye"></i>本站总访问量 site_pv_footer: 次 # custom pv span for one page only page_pv: true page_pv_header: 本文总阅读量 # <i class="fa fa-file-o"></i> page_pv_footer: 次