前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Hexo + Butterfly 自定义页脚

Hexo + Butterfly 自定义页脚

作者头像
唐志远
发布于 2023-04-22 11:55:44
发布于 2023-04-22 11:55:44
61100
代码可运行
举报
文章被收录于专栏:FE32 CodeFE32 Code
运行总次数:0
代码可运行

效果预览

3.7.1 版本效果

4.5.1 版本效果

这里用 4.5.1 版本跑了【自定义页脚】的功能,主题是新拉的,可能未过多美化,只是为了验证下该功能有没有问题。如果你在使用此功能时遇见了 BUG ,请检查footer.pug的格式以及custom.css是否正确引入。

本人用的是npm方式安装的 hexo-theme-butterfly,后续魔改时更改的文件都是【BlogRoot/node_modules/hexo-theme-butterfly】文件夹中的文件。如果你是git clone方式安装的主题,请在【BlogRoot/themes/butterfly】文件夹下修改对应的文件。

步骤

BlogRoot/node_modules/hexo-theme-butterfly/layout/includes/footer.pug中添加如下代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#footer-wrap
  #ft
    .ft-item-1
      .t-top
        .t-t-l
          p.ft-t.t-l-t 说点什么
          .bg-ad
            div
              | (这里的内容随你写,但是不要过长影响整体美观度,具体可根据实现效果修改)随便说点什么说点什么、随便说点什么说点什么随便说点什么说点什么随便说点什么说点什么随便说点什么说。
            .btn-xz-box
              a.btn-xz(href='https://tzy1997.com/') 点击跳转到哪儿
        .t-t-r
          p.ft-t.t-l-t 修仙导航
          ul.ft-links
            li
              a(href='https://tzy1997.com/articles/hexo1600/') 建站指南
              a(href='https://tzy1997.com/nav.html') 网址导航
            li
              a(href='https://tzy1997.com/sponsorWall/') 来杯咖啡
              a(href='https://tzy1997.com/comments/') 留点什么
            li
              a(href='https://tzy1997.com/about/') 关于博主
              a(href='https://tzy1997.com/archives/') 文章归档
            li
              a(href='https://tzy1997.com/categories/') 文章分类
              a(href='https://tzy1997.com/tags/') 文章标签
            li
              a(href='https://tzy1997.com/gallery/') 我的相册
              a(href='https://tzy1997.com/bangumis/') 我的追番
            li
              a(href='https://tzy1997.com/specialEffects/') 一些特效
              a(href='https://tzy1997.com/wallpaper/') 一些壁纸
    .ft-item-2
      p.ft-t 推荐友链
      .ft-img-group
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
        .img-group-item
          a(href='https://tzy1997.com/')
            img(src='https://bu.dusays.com/2022/05/02/626f92e193879.jpg' alt='')
  if theme.footer.owner.enable
    - var now = new Date()
    - var nowYear = now.getFullYear()
    if theme.footer.owner.since && theme.footer.owner.since != nowYear
      .copyright!= `&copy;${theme.footer.owner.since} - ${nowYear + ' '} <i id="heartbeat" class="fa fas fa-heartbeat"></i> ${config.author}`
    else
      .copyright!= `&copy;${nowYear + ' '} <i id="heartbeat" class="fa fas fa-heartbeat"></i> ${config.author}`
  if theme.footer.copyright
    .framework-info
      span= _p('footer.framework') + ' '
      a(href='https://hexo.io')= 'Hexo'
      span.footer-separator |
      span= _p('footer.theme') + ' '
      a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
  if theme.footer.custom_text
    .footer_custom_text!=`${theme.footer.custom_text}`

你需要添加的代码为#ft整个 div,注意在缩进上与主题的几个if对齐。这里你可以根据自己的需求修改以上内容等,例如【说点什么】、自定义底部导航链接等,【推荐友链】的图片尺寸建议 1:1。

将以下代码复制到自定义的custom.css中,不会自定义css的请阅读 Hexo + Butterfly 一些常见问题 一文中关于【关于自定义的 js 和 css 文件】部分。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
/* 自定义底部  start */
#ft {
    max-width: 1200px;
    margin: 0 auto 12px;
    display: flex;
    color: rgb(255 255 255 / 80%) !important;
    text-align: left;
    flex-wrap: wrap;
}

.ft-item-1,
.ft-item-2 {
    display: flex;
    height: 100%;
    padding: 10px 14px;
}

.ft-item-1 {
    flex-direction: column;
    flex: 2;
}

.ft-item-2 {
    flex: 1;
    flex-direction: column;
}

.t-top {
    display: flex;
}

.t-top .t-t-l {
    display: flex;
    flex-direction: column;
    flex: 1.4;
    margin-right: 10px;
}

.t-top .t-t-l .bg-ad {
    width: 85%;
    border-radius: 10px;
    padding: 0 10px;
}

.btn-xz-box {
    margin-top: 10px;
}

.btn-xz {
    display: block;
    background-color: var(--btn-bg);
    color: var(--btn-color);
    text-align: center;
    line-height: 2.4;
    margin: 8px 0;
    cursor: pointer !important;
}

.btn-xz:hover {
    text-decoration: none !important;

}

.btn-xz-box:hover .btn-xz {
    background-color: #6f42c1;
}

.t-top .t-t-r {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.ft-links {
    padding: 0 14px;
    list-style: none;
    margin-top: 0 !important;
}

.ft-links li a {
    display: inline-block !important;
    width: 50%;
    cursor: pointer !important;
}

.ft-links li a:hover {
    text-decoration: none !important;
    color: #6f42c1 !important;
}

.ft-item-2 .ft-img-group {
    width: 100%;
}

.ft-t {
    font-size: 0.8rem;
    margin-bottom: 20px;
    line-height: 1;
    font-weight: 600;
}

.t-l-t {
    padding-left: 14px;
}

.ft-item-2 .ft-img-group .img-group-item {
    display: inline-block;
    width: 18.4%;
    margin-right: 14px;
    margin-bottom: 6px;
}

.ft-item-2 .ft-img-group .img-group-item a {
    display: inline-block;
    width: 100%;
    height: 100%;
    cursor: pointer !important;
}

.ft-item-2 .ft-img-group .img-group-item a img {
    width: 100%;
    max-height: 80px;
}

@media screen and (max-width: 768px) {

    .ft-item-1 {
        flex-basis: 100% !important;
    }

    .ft-item-2 {
        flex-basis: 100% !important;
    }

    .t-top .t-t-l .bg-ad {
        width: 100%;
    }
}

@media screen and (max-width: 576px) {
    .t-top {
        flex-wrap: wrap;
    }

    .t-top .t-t-l {
        flex-basis: 100% !important;

    }

    .t-top .t-t-r {
        margin-top: 16px;
        flex-basis: 100% !important;
    }
}
/* 自定义底部  End */

css 中的#6f42c1是我的主题色,这里记得换成你的主题色。

到这里你已经成功了 99.99%,最后重新编译运行即可看见效果。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-12-09,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
基于 Hexo 从零开始搭建个人博客(六)
2021-04-27 butterfly3.4.0 -> butterfly3.7.1
唐志远
2022/10/27
1.1K0
基于 Hexo 从零开始搭建个人博客(六)
Hexo-Butterfly主题修改分享
首先\themes\butterfly\source\css路径下创建一个css文件,比如ahzoo.css
十玖八柒
2022/11/02
9360
Hexo-Butterfly主题修改分享
优雅的使用Webstack打造个人网址导航
一款基于 WebStackPage 的 Hexo 主题。本人选择的是 hexo-theme-webstack。
唐志远
2023/08/01
7980
优雅的使用Webstack打造个人网址导航
Hexo-Butterfly主题修改记录-2
添加跳动的心 首先在博客引入这个开源css \themes\butterfly\layout\includes\footer.pug,找到此段代码:
十玖八柒
2022/08/01
1.7K0
Hexo-Butterfly主题修改记录-2
Hexo + Butterfly 侧边栏公众号
本人用的是npm方式安装的 hexo-theme-butterfly,后续魔改时更改的文件都是【BlogRoot/node_modules/hexo-theme-butterfly】文件夹中的文件。如果你是git clone方式安装的主题,请在【BlogRoot/themes/butterfly】文件夹下修改对应的文件。
唐志远
2023/04/22
6300
Hexo + Butterfly 侧边栏公众号
请收下这只可爱的猫咪吧
制作一个盛放内容的盒子,在BlogRoot/themes/butterfly/layout/includes/head.pug最后一行加入如下代码:
唐志远
2023/08/01
2170
请收下这只可爱的猫咪吧
基于Butterfly的外挂标签引入
Note标签外挂有两种用法。icons和light_bg_offset只对方法一生效。
唐志远
2023/08/01
4680
基于Butterfly的外挂标签引入
关于 Hexo + Butterfly 的常见问题
如果改动了站点配置文件_config.yml 和主题配置文件_config.butterfly.yml,需要重新编译才能看到效果。
唐志远
2022/10/27
2.4K0
关于 Hexo + Butterfly 的常见问题
Hexo添加首页置顶轮播图
在写系列博文时对于某一篇文章的寻找过程会比较繁琐(对于博主而言自然会简单些,但是对于访客来讲就没那么轻松),因此参考Akilar的博文弄了一个置顶轮播图。可以把系列博文的链接汇总起来做一个索引,放置在轮播图中。这样既可以展示博主想对外展示的内容,又方便快速进行文章跳转。
花猪
2022/02/22
1.1K0
Hexo添加首页置顶轮播图
Hexo-Butterfly主题魔改
本文章首发于语雀! 通过各种高科技功能同步到Hajeekn 的博客 由于每个人的博客目录都不相同,这里博客目录使用%brt%代替 本文章除 Pace wowjs 普通引入法以外,其他魔改都不适合 Butterfly3.6.0 及以上
FloatSheep
2022/04/25
2.6K0
Hexo-Butterfly主题魔改
基于 Hexo 从零开始搭建个人博客(五)
修改网站各种资料,例如标题、副标题和邮箱等个人资料,请修改站点配置文件_config.yml。部分参数如下,详细参数可参考官方的配置描述。
唐志远
2022/10/27
1.2K0
基于 Hexo 从零开始搭建个人博客(五)
Hexo-悬挂灯笼
新建CSS样式 在BlogRoot/node_modules/hexo-theme-butterfly/source/css文件下新建 CSS 文件,并命名为 lantern.css( 当然名字随便取,只要在主题配置文件中引入对应的CSS文件即可 ),将以下代码复制到新建的lantern.css中。
唐志远
2022/10/27
3080
Hexo-悬挂灯笼
Hexo修改友链界面
之前看到友链界面的修改需要动大量源码,就没有弄。后来逐渐开始摸索、修改。自己表示很满意,按照各路大神的教程来操作也并不难。效果展示可以点击我的友链页面查看。
花猪
2022/02/16
8910
Butterfly美化
最最最开始的,好不容易搭建了自己的个人博客,当然要写上自己的名字、签名…,证明身份。而且身为一个Chinese,还是中文舒服,所以主目录下_config.yml的配置文件:
张小驰出没
2021/04/15
3.5K0
Butterfly美化
7b2美化-添加好看的底部介绍
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
小狐狸说事
2022/11/16
7000
7b2美化-添加好看的底部介绍
Hexo + Butterfly 自定义右键菜单
在BlogRoot/node_modules/hexo-theme-butterfly/layout/includes文件夹下新建一个right-menu的文件夹,在此文件夹下新建一个index.pug文件。 具体位置如下图:
唐志远
2022/10/27
5760
Hexo + Butterfly 自定义右键菜单
hexo-butterfly美化 (持续更新)
把下载好的Js文件放在theme/Butterfly/source/js文件夹下 /Butterfly/layout/includes文件夹下找到head.pug文件,在最后引入
匿名用户的日记
2021/12/14
1.4K0
hexo-butterfly美化 (持续更新)
基于 Hexo 从零开始搭建个人博客(四)
Front-matter 是 markdown 文件最上方以---分隔的区域,用于指定个别档案的变数。
唐志远
2022/10/27
3770
基于 Hexo 从零开始搭建个人博客(四)
主题修改记录
在\themes\butterfly\layout\includes\header\index.pug中添加以下内容
用户1316967
2022/01/18
1K0
Hexo博客 | 如何为博客添加顶部轮播图和文章推荐卡片
最近看了zhheo大佬的博客首页,发现大佬的布局还是那么的好看,于是果断COPY,再加上我一直想要在我的博客首页加一个大画幅的轮播图插件,于是又参考了Hassan的文章轮播图…经过一番折腾,效果如下:
Justlovesmile
2022/09/02
1.3K1
Hexo博客 | 如何为博客添加顶部轮播图和文章推荐卡片
相关推荐
基于 Hexo 从零开始搭建个人博客(六)
更多 >
领券
💥开发者 MCP广场重磅上线!
精选全网热门MCP server,让你的AI更好用 🚀
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验