HiNinoJay / hexo-theme-A4

A hexo theme that looks like an A4 paper.(一个类A4纸张质感的hexo博客主题。)
https://ninojay.top
MIT License
313 stars 22 forks source link

Customized favicon 404 on Non-index pages -- Possible cause & Possible fix #96

Closed Tonkovski closed 7 months ago

Tonkovski commented 7 months ago

Thanks for spending time viewing this issue, and hope this will be of some help.

After changing favicon in _config.a4.yml the theme will be unable to locate exact location of modified favicon path.

E.g. If the config is modified as follows:

# 相对于source目录下的头像url
favicon: /img/favicon.jpeg

This is what the page looks like:

ScreenCapture

The issue is possibly caused by codes in /blob/main/layout/_partial/post-header.ejs where the avatar is defined as follows:

    <div class="header-container">
        <img style="
        width: 56px;
        height: auto;" alt="^-^" cache-control="max-age=86400" class="header-img" src="<%- url_for('/img/favicon.webp') %>" width="10%"></img>
        <div class="header-content">
            <a class="logo" href="<%- url_for() %>"><%= config.title %></a> 
            <span class="description"><%= config.description %></span> 
        </div>

    </div>

Changing url_for('/img/favicon.webp') into url_for(theme.favicon) fixes this issue.

capt2
HiNinoJay commented 7 months ago

nice issue, thanks a lot.🍺

The problem has been fixed.

If you are using git installation, you can pull down the code again. If you use npm, it will be updated in the next version. v1.8.4 has been released