测试第二篇文章 TBQ 2025-08-04 2025-08-06 AnZhiYu主题美化详细教程
基于AnZhiYu官方文档的完整美化指南
🎯 前言 AnZhiYu是一个基于Butterfly主题魔改的Hexo主题,拥有极佳的视觉效果和丰富的自定义功能。本教程将带你从基础配置到高级美化,打造专属的博客站点。
📋 目录
主题安装与基础配置
外观美化配置
首页布局优化
导航栏自定义
侧边栏美化
页面个性化
特色功能启用
高级自定义
🚀 主题安装与基础配置 1. 主题安装 方法一:Git安装(推荐) 1 2 cd your-hexo-sitegit clone -b main https://github.com/anzhiyu-c/hexo-theme-anzhiyu.git themes/anzhiyu
方法二:下载安装
访问 AnZhiYu GitHub
下载最新版本
解压到 themes/anzhiyu
目录
2. 应用主题 修改站点根目录下的 _config.yml
:
3. 安装必要依赖 1 npm install hexo-renderer-pug hexo-renderer-stylus --save
🎨 外观美化配置 1. 主题色彩配置 在主题配置文件 _config.anzhiyu.yml
中配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 theme_color: enable: true main: "#425AEF" paginator: "#425AEF" button_hover: "#318ce7" text_selection: "#425AEF" link_color: "#425AEF" meta_color: "#858585" hr_color: "#A4D8FA" code_foreground: "#F47466" code_background: "rgba(27, 31, 35, .05)" toc_color: "#425AEF" blockquote_color: "#425AEF"
2. 深色模式配置 1 2 3 4 5 6 7 darkmode: enable: true button: true autoswitch: false start: end:
3. 背景设置 1 2 3 4 5 6 7 background: enable: true opacity: 0.2 dark_opacity: 0.3 url: https://your-image-url.jpg dark_url: https://your-dark-image-url.jpg
🏠 首页布局优化 1. 顶部大图配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 index_img: https://your-index-image.jpg default_top_img: https://your-default-image.jpg archive_img: https://your-archive-image.jpg tag_img: https://your-tag-image.jpg category_img: https://your-category-image.jpg
2. 首页文章显示模式 1 2 3 4 5 6 7 index_layout: 3 index_post_content: method: 2 length: 500
3. 首页社交图标 1 2 3 4 5 6 7 social: fas fa-envelope: mailto:your-email@example.com || Email || "#425AEF" fab fa-github: https://github.com/yourname || Github || "#24292e" fab fa-telegram: https://t.me/yourname || Telegram || "#24A1DE" fab fa-qq: http://wpa.qq.com/msgrd?v=3&uin=yourqq || QQ || "#12B7F5" fas fa-rss: /atom.xml || RSS || "#FFA500"
🧭 导航栏自定义 1. 导航栏配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 nav: logo: display_title: true fixed: false menu: 首页: / || fas fa-home 归档: /archives/ || fas fa-archive 标签: /tags/ || fas fa-tags 分类: /categories/ || fas fa-folder-open 友链: /link/ || fas fa-link 关于: /about/ || fas fa-heart 音乐: /music/ || fas fa-music 相册: /gallery/ || fas fa-images
2. 导航栏样式 1 2 3 4 5 6 7 8 9 nav_bg: enable: true opacity: 0.8 navbar_color: enable: true color: "#ffffff"
📱 侧边栏美化 1. 个人信息卡片 1 2 3 4 5 6 7 author_info: enable: true Avatar_img: https://your-avatar.jpg Wechat_img: https://your-wechat-qr.jpg Qq_img: https://your-qq-qr.jpg description: "Your description here"
2. 公告栏 1 2 3 4 announcement: enable: true content: "欢迎来到我的博客!"
3. 侧边栏组件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 aside: enable: true hide: false button: true mobile: true position: right display: archive: true tag: true category: true card_author: enable: true description: true button: enable: true icon: fab fa-github text: Follow Me link: https://github.com/yourname card_announcement: enable: true content: "This is my Blog" card_recent_post: enable: true limit: 5 sort: date card_categories: enable: true limit: 8 expand: none card_tags: enable: true limit: 40 color: false card_archives: enable: true type: monthly format: MMMM YYYY order: -1 limit: 8 card_webinfo: enable: true post_count: true last_push_date: true
📄 页面个性化 1. 文章页面配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 post: meta: author: enable: true date: enable: true format: "YYYY-MM-DD" updated: enable: true format: "YYYY-MM-DD" categories: enable: true tags: enable: true award: enable: true QR_code: https://your-reward-qr.jpg wechat: https://your-wechat-pay.jpg alipay: https://your-alipay.jpg
2. 版权信息 1 2 3 4 5 6 7 post_copyright: enable: true decode: false author_href: https://your-blog.com license: CC BY-NC-SA 4.0 license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/
3. 目录设置 1 2 3 4 5 6 7 toc: post: true page: true number: true expand: false style_simple: false scroll_percent: true
✨ 特色功能启用 1. 音乐播放器 1 2 3 4 5 6 7 global_music: enable: true type: "custom" server: "netease" type: "playlist" id: "your-playlist-id"
2. 鼠标点击特效 1 2 3 4 5 6 7 click_heart: enable: true fireworks: enable: true
3. 樱花飘落特效
4. 彩带特效 1 2 3 4 5 6 7 canvas_ribbon: enable: true size: 150 alpha: 0.6 zIndex: -1 click_to_change: false
5. 网站运行时间 1 2 3 4 runtimeshow: enable: true publish_date: "2023/01/01 00:00:00"
🔧 高级自定义 1. 自定义CSS 在主题目录下创建 source/css/_custom.styl
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 :root --anzhiyu-main : #425AEF --anzhiyu-main-op : #425AEF23 --anzhiyu-main-op-deep : #425AEF88 .card-widget border-radius : 8px .button--animated transition : all 0.3s ease &:hover transform : translateY (-2px ) box-shadow : 0 4px 8px rgba (0 ,0 ,0 ,0.2 )
2. 自定义JavaScript 在主题目录下创建 source/js/custom.js
:
1 2 3 4 5 6 7 8 9 10 document .addEventListener ('DOMContentLoaded' , function ( ) { console .log ('AnZhiYu theme loaded!' ); document .addEventListener ('click' , function (e ) { }); });
3. 注入代码 1 2 3 4 5 6 inject: head: - <link rel="stylesheet" href="/css/custom.css"> bottom: - <script src="/js/custom.js"></script>
4. 字体配置 1 2 3 4 5 6 font: global-font-size: 14px code-font-size: 14px font-family: -apple-system, BlinkMacSystemFont, "Segoe UI" , "Helvetica Neue" , Lato, Roboto, "PingFang SC" , "Microsoft JhengHei" , "Microsoft YaHei" , sans-serif code-font-family: consolas, Menlo, "PingFang SC" , "Microsoft JhengHei" , "Microsoft YaHei" , sans-serif
🎪 页面模板创建 1. 创建友链页面
在 source/link/index.md
中添加:
1 2 3 4 5 --- title: 友情链接 date: 2023-01-01 00:00:00 type: "link" ---
2. 创建关于页面
3. 创建相册页面
在 source/gallery/index.md
中添加:
1 2 3 4 5 --- title: 相册 date: 2023-01-01 00:00:00 type: "gallery" ---
📊 SEO优化配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 SEO: enable: true author: "Your Name" description: "Your blog description" keywords: "blog, hexo, anzhiyu" site_verification: google: "your-google-verification-code" baidu: "your-baidu-verification-code" Open_Graph_meta: enable: true option: type: website image: https://your-og-image.jpg
🎯 性能优化 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 compress: enable: true pwa: enable: true manifest: /manifest.json apple_touch_icon: /apple-touch-icon.png favicon_32_32: /favicon-32x32.png favicon_16_16: /favicon-16x16.png mask_icon: /safari-pinned-tab.svg preloader: enable: true source: 1
📝 写作优化 1. Front-matter模板 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 --- title: 文章标题 date: 2023-01-01 12:00:00 updated: 2023-01-01 12:00:00 tags: - 标签1 - 标签2 categories: - 分类1 description: 文章描述 cover: https://cover-image.jpg top_img: https://top-image.jpg comments: true toc: true toc_number: true copyright_author: Your Name copyright_url: https://your-blog.com copyright_info: 本文采用CC BY-NC-SA 4.0 协议 ---
2. 代码高亮配置 1 2 3 4 highlight_theme: mac highlight_copy: true highlight_lang: true highlight_shrink: false
🚀 部署优化 1. 生成与部署 1 2 3 4 5 6 7 8 9 10 11 hexo clean hexo generate hexo server hexo deploy
2. 自动部署配置 在 _config.yml
中配置:
1 2 3 4 deploy: type: git repo: https://github.com/yourusername/yourusername.github.io.git branch: main
🎨 主题定制技巧 1. 颜色搭配建议
蓝色系 :#425AEF
(默认)
绿色系 :#4CAF50
紫色系 :#9C27B0
橙色系 :#FF9800
红色系 :#F44336
2. 图片建议
首页大图 :1920x1080px
文章封面 :1200x630px
头像 :200x200px
背景图 :支持各种尺寸
3. 常见问题解决
样式不生效 :清理缓存后重新生成
图片不显示 :检查URL是否正确
配置错误 :对比官方配置文件格式
功能异常 :检查依赖是否安装完整
📖 参考资源
通过以上配置,你就可以打造出一个美观、功能丰富的AnZhiYu主题博客了!记住要根据自己的需求调整配置,不断优化和完善你的博客。
小提示 :建议先完成基础配置,确保主题正常运行后,再进行高级美化,避免配置冲突导致的问题。