Hexo | yilia主题下给github.io博客添加标签云

本文介绍了如何在Hexo的yilia主题下为GitHub.io博客添加标签云。通过编辑主题配置文件并引入特定代码,实现标签云页面的自动生成和展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

让 Hexo 自动生成 Tag Cloud 标签云页面

在主题yilia 中,须在 theme/yilia/layout/_partial/article.ejs下, div article-entry 中插入代码。

<div class="article-entry" itemprop="articleBody">
    <% if (post.excerpt && index){ %>
        <%- post.excerpt %>
    <% } else { %>
        <% if (page.path === "tags/index.html"){ %>
            <引入 tags 页面的代码>
        <% } %>
        <%- post.content %>
    <% } %>
</div>

<引入tags页面的代码>为:

<% if (page.path === "tags/index.html"){ %>
    <hr>
    <br>
    <%- list_categories({
        depth: 1,
    }) %>
    <div class="tags">
        <%- tagcloud({
            min_font: 16, 
            max_font: 35, 
            amount: 999, 
            color: true, 
            start_color: 'gray', 
            end_color: 'black',
        }) %>
    </div>
    <style>
        .category-list li{
            display: inline-block;
            margin: 0 1em .5em 0;
            padding: 4px;
            border: 1px solid lightgray;
            font-size: 1.2em;
        }
        .category-list a {
            color: gray;
        }
        .category-list-item:hover a {
            color: gray;
            text-decoration: none;
            font-weight: bold;
        }
        .category-list-count {
            margin-left: 2px;
            font-size: .9em;
        }
        .article-entry ul li:before{
            display: none;
        }
        .article-inner  {
            text-align: center;
        }
        .tags {
            max-width: 40em;
            margin: 2em auto;
            margin-top: 0em;
        }
        .tags a {
            margin-right: 1em;
            border-bottom: 1px solid gray;
            line-height: 65px;
            white-space: nowrap;
        }
        .tags a:hover {
            border-bottom: 2px solid black;
            font-style: italic;
            text-decoration: none;
        }
    </style>
<% } %>
http://"主页"/tags/页面的显示

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值