Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO Issue: Page has links to redirect #1314

Open
guoapeng opened this issue Aug 13, 2024 · 0 comments
Open

SEO Issue: Page has links to redirect #1314

guoapeng opened this issue Aug 13, 2024 · 0 comments
Labels
feature:general Feature request that affects this theme in general.

Comments

@guoapeng
Copy link

guoapeng commented Aug 13, 2024

确保你在提交Bug反馈之前仔细阅读了Hexo文档Icarus用户指南,和GitHub issues来了解你的问题是否已经被他人提出过。

Bug描述
简洁清晰地描述你遇到的Bug是什么。

Ahrefs SEO 问题报告中多达 251 个Page has links to redirect, 我的内容页面也就259个,最后发现是profile widget下面的 archives, categories, tags 链接有问题,正确的连接应该是 例如https://pengtech.net/archives/ 但是icarus theme生成的连接是https://pengtech.net/archives 尾巴上少了一个正斜杠,导致了redirect. SEO report 如下:

image

系统与环境
列出你的Hexo和Icarus的版本和配置。

$hexo version
INFO  Validating config
Inferno is in development mode.
INFO  DPlayer.min.css is not found in this version of dplayer, skip it.
INFO  =======================================
 ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
 ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
 ██║██║     ███████║██████╔╝██║   ██║███████╗
 ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
 ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
 ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO  === Checking package dependencies ===
INFO  === Checking theme configurations ===
INFO  === Registering Hexo extensions ===
hexo: 7.3.0
hexo-cli: 4.3.2
os: linux 6.8.8-300.fc40.x86_64 Fedora Linux 40 (Workstation Edition)
node: 20.12.2
acorn: 8.11.3
ada: 2.7.6
ares: 1.27.0
base64: 0.5.2
brotli: 1.1.0
cjs_module_lexer: 1.2.2
cldr: 44.1
icu: 74.2
llhttp: 8.1.2
modules: 115
napi: 9
nghttp2: 1.60.0
nghttp3: 0.7.0
ngtcp2: 0.8.1
openssl: 3.0.13+quic
simdutf: 4.0.8
tz: 2024a
undici: 5.28.4
unicode: 15.1
uv: 1.46.0
uvwasi: 0.0.20
v8: 11.3.244.8-node.19
zlib: 1.3.0.1-motley-40e35a7
  • Hexo,操作系统,和Node.js的版本(使用hexo version命令来查看)
  • 站点配置文件_config.yml
  • 主题配置文件_config.icarus.ymlthemes/icarus/_config.yml
  • 其他额外的配置文件(文章front-matter,_config.post.yml,或_config.page.yml
  • 浏览器版本(如Firefox 70.0,Chrome Android 80.0)

复现方式
列出复现这个Bug的步骤,如:

看我的SEO截图,看红色标记部分。

  1. 访问‘...’
  2. 点击’...‘
  3. 下拉到‘...’
  4. 出现‘...’的错误

期望行为
简洁清晰地描述没有这个情况下你期望得到的结果。
期望profile widget上的连接结尾加上正斜杠,避免301 redirect请求

截图
如果可以的话,请附上几张截图来帮助说明你遇到的问题。

额外上下文
附上与问题有关的其他上下文信息。

出现问题的代码位于:
themes/icarus/layout/widget/profile.jsx

    return {
        avatar: getAvatar(),
        avatarRounded: avatar_rounded,
        author,
        authorTitle: author_title,
        location,
        counter: {
            post: {
                count: postCount,
                title: _p('common.post', postCount),
                url: url_for('/archives')
            },
            category: {
                count: categoryCount,
                title: _p('common.category', categoryCount),
                url: url_for('/categories')
            },
            tag: {
                count: tagCount,
                title: _p('common.tag', tagCount),
                url: url_for('/tags')
            }
        },

same issue on tags breadcrumb navigation

themes/icarus/layout/tag.jsx

module.exports = class extends Component {
    render() {
        const { config, page, helper } = this.props;
        const { url_for, _p } = helper;

        return <Fragment>
            <div class="card">
                <div class="card-content">
                    <nav class="breadcrumb" aria-label="breadcrumbs">
                        <ul>
                            <li><a href={url_for('/tags')}>{_p('common.tag', Infinity)}</a></li>
                            <li class="is-active"><a href="#" aria-current="page">{page.tag}</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
            <Index config={config} page={page} helper={helper} />
        </Fragment>;
    }
};

<li><a href={url_for('/tags')}>{_p('common.tag', Infinity)}</a></li>

生成的连接结尾没有正斜杠,导致301 redirect, 最终导致很多错误报告在SEO report中。

same issue on category breadcrumb nav links
themes/icarus/layout/category.jsx

module.exports = class extends Component {
    render() {
        const { config, page, helper } = this.props;
        const { url_for, _p } = helper;

        return <Fragment>
            <div class="card">
                <div class="card-content">
                    <nav class="breadcrumb" aria-label="breadcrumbs">
                        <ul>
                            <li><a href={url_for('/categories')}>{_p('common.category', Infinity)}</a></li>
                            {page.parents.map(category => {
                                return <li><a href={url_for(category.path)}>{category.name}</a></li>;
                            })}
                            <li class="is-active"><a href="#" aria-current="page">{page.category}</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
            <Index config={config} page={page} helper={helper} />
        </Fragment>;
    }
};
  • {_p('common.category', Infinity)}
  • @ppoffice ppoffice added the feature:general Feature request that affects this theme in general. label Aug 14, 2024
    forgetfulengineer added a commit to forgetfulengineer/hexo-theme-icarus that referenced this issue Oct 3, 2024
    ppoffice added a commit that referenced this issue Oct 4, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    feature:general Feature request that affects this theme in general.
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants