目 录CONTENT

文章目录

Halo博客:如何将404页面修改为“宝贝回家404”

慧行说
2023-05-24 / 2 评论 / 0 点赞 / 1,304 阅读 / 912 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2023-05-24,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

早在2018年的时候我将网站从WordPress搬迁至hexo的时候,我偶然发现了一个宝贝回家的404页面,我觉得这个404页面非常有意义,于是我便将我自己网站的404页面设置为了宝贝回家。现在搬迁至halo了,我想能不能也替换为宝贝回家404页面呢?于是我在研究joe2.0主题的时候发现了其实可以很方便的修改。

  • 首先打开主题目录,找到404.ftl,见下图:

image-20230524220342494

  • 然后修改当前文件为以下代码:
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8;"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="robots" content="all" />
  <meta name="robots" content="index,follow"/>
  <link rel="stylesheet" type="text/css" href="https://qzone.qq.com/gy/404/style/404style.css">
</head>
<body>
  <script type="text/javascript" src="//qzonestyle.gtimg.cn/qzone/hybrid/app/404/search_children.js" charset="utf-8" homePageUrl="/"
          homePageName="回到我的主页">
  </script>
  <script src="https://qzone.qq.com/gy/404/data.js" charset="utf-8"></script>
  <script src="https://qzone.qq.com/gy/404/page.js" charset="utf-8"></script>
</body>
</html>
  • 修改成功之后访问404页面或错误页面将显示如下:

image-20230524222127136

下面是joe2.0原404代码:

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <title>未找到您要的资源</title>
    <meta name="renderer" content="webkit">
    <meta name="format-detection" content="email=no">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover">
    <meta name="keywords" content="${meta_keywords!}">
    <meta name="description" content="${meta_description!}">
    <meta name="author" content="${user.nickname!}">
    <meta name="site" content="${blog_url!}">
    <link rel="shortcut icon" size="32x32" href="${options.blog_favicon!}">
    <#include "template/config.ftl">
    <style>
      html, body {
        width: 100%;
        height: 100%;
        overflow: hidden;
      }
      .joe_page_404 {
          position: absolute;
          z-index: 10;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          background: #fff;
          color: #666;
          text-align: center;
          display: -webkit-box;
          display: -ms-flexbox;
          display: flex;
          -webkit-box-pack: center;
          -ms-flex-pack: center;
          justify-content: center;
          -webkit-box-align: center;
          -ms-flex-align: center;
          align-items: center;
          -webkit-box-orient: vertical;
          -webkit-box-direction: normal;
          -ms-flex-direction: column;
          flex-direction: column;
          font-family: sans-serif;
          -ms-text-size-adjust: 100%;
          -webkit-text-size-adjust: 100%;
          -webkit-font-smoothing: antialiased;
      }
      .joe_page_404 .error {
        margin-top: -10vh;
      }
      .joe_page_404 img {
        width: 60%;
        max-width: 700px;
      }
      .joe_page_404 .title {
        font-size: 30px;
        margin-top: 20px;
        margin-bottom: 40px;
        -webkit-user-select: none;
        user-select: none;
        font-weight: 300;
        color: #888;
      }
      .joe_page_404 .error_link {
        padding: 12px 36px;
        font-size: 14px;
        text-decoration: none;
        -webkit-user-select: none;
        user-select: none;
        color: #999;
        border: 1px solid #999;
        border-radius: 100px;
        -webkit-transition: color .3s;
        transition: color .3s;
      }
      .joe_page_404 .error_link:hover {
        color: #6c63ff;
        border-color: #6c63ff;
      }
      @media screen and (max-width:500px) {
        .joe_page_404 .title {
          font-size: 20px;
        }
        .joe_page_404 .error_link {
          padding: 10px 30px;
        }
      }
      @media screen and (max-height:500px) {
        .joe_page_404 .title {
          font-size: 20px;
        }
        .joe_page_404 img {
          width: 30%;
        }
        .joe_page_404 .error_link {
          padding: 10px 30px;
        }
      }
    </style>
  <head>
  <body>
    <div class="joe_page_404">
      <div class="error">
        <img src="${BASE_RES_URL!}/source/svg/404.svg" alt="404">
        <h3 class="title">“未找到您要的资源”</h3>
        <a href="/" class="error_link">回到主页</a>
      </div>
    </div>
  </body>
</html>
0

评论区