修改404页面
修改路径[you_blog]\themes/butterfly/layout/includes/404.pug
文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| - var top_img = theme.error_404.background || theme.default_top_img - var bg_img = `background-image: url('${url_for(top_img)}')`
#body-wrap.error div(style='display: none') include ./header/index.pug
#error-wrap .error-content .error-img(style=bg_img) .error-info h1.error_title= '404' .error_subtitle= theme.error_404.subtitle a.button--animated(href=config.root) i.fas.fa-rocket = _p('回到主页') .aside-list .aside-list-group - let postLimit = theme.aside.card_recent_post.limit === 0 ? site.posts.length : theme.aside.card_recent_post.limit || 5 - let sort = theme.aside.card_recent_post.sort === 'updated' ? 'updated' : 'date' - site.posts.sort(sort, -1).limit(postLimit).each(function(article){ - let link = article.link || article.path - let title = article.title || _p('no_title') - let no_cover = article.cover === false || !theme.cover.aside_enable ? 'no-cover' : '' - let post_cover = article.cover .aside-list-item(class=no_cover) if post_cover && theme.cover.aside_enable a.thumbnail(href=url_for(link) title=title) img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title) .content a.title(href=url_for(link) title=title)= title if theme.aside.card_recent_post.sort === 'updated' time(datetime=date_xml(article.updated) title=_p('post.updated') + ' ' + full_date(article.updated)) #[=date(article.updated, config.date_format)] else time(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)] - })
|
增加css
在自定义css
中加入以下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| #error-wrap{ top: 40%; position: absolute; right: 0; left: 0; margin: 0 auto; padding: 0 1rem; max-width: 1000px; transform: translate(0,-50%); } #error-wrap .error-content { display: flex; -webkit-box-orient: horizontal; flex-direction: row; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; margin: 0 1rem; height: 18rem; transition: all .3s ease 0s; box-shadow: none!important; border-radius: 12px; background: #fff !important; } #error-wrap .error-content .error-img { -webkit-box-flex: 1; flex: 1 1 0%; height: 100%; border-top-left-radius: 8px; border-bottom-left-radius: 8px; background-color: #307af6; background-position: center center; background-size: cover; } #error-wrap .error-content .error-info { -webkit-box-flex: 1; flex: 1 1 0%; padding: .5rem; text-align: center; font-size: 14px; font-family: "PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif; } #error-wrap .error-content .error-info .error_title{ margin-top: -3rem!important; font-size: 9em; padding-top: 0; padding-left: 0!important; } #error-wrap .error-content .error-info .error_subtitle { margin-top: -3.5rem; word-break: break-word; font-size: 1.6em; -webkit-line-clamp: 2; } #error-wrap .error-content .error-info a { display: inline-block; margin-top: .5rem; padding: .3rem 1.5rem; background: #3f3f3f; color: #fff; } #error-wrap .error-content .error-info a i { padding-right: .3rem; } #body-wrap.error .aside-list{ display: flex; flex-direction: row; flex-wrap: nowrap; bottom: 0px; position: absolute; padding: 1rem; width: 100%; overflow: scroll; } #body-wrap.error .aside-list .aside-list-group{ display: flex; flex-direction: row; flex-wrap: nowrap; max-width: 1200px; margin: 0 auto; } #body-wrap.error .aside-list .aside-list-item{ padding: 0.5rem; } #body-wrap.error .aside-list .aside-list-item img{ width: 100%; object-fit: cover; border-radius: 12px; } #body-wrap.error .aside-list .aside-list-item .thumbnail{ overflow: hidden; width: 230px; height: 143px; background: #fff; display: flex; } #body-wrap.error .aside-list .aside-list-item .content .title{ -webkit-line-clamp: 2; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; line-height: 1.5; justify-content: center; align-items: flex-end; align-content: center; padding-top: 0.5rem; } #body-wrap.error .aside-list .aside-list-item .content time{ display: none; }
|
修改配置项
在[you_blog]\_config.butterfly.yml
中修改配置项:
1 2 3 4 5
| error_404: enable: true subtitle: '请尝试站内搜索寻找文章' background: /img/404.gif
|
参考链接
14-分类标签归档页增加文章索引
12-添加51统计