Skip to content

Commit

Permalink
修复SEO的问题和增加归档页年、月的超链接
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkfox committed Oct 14, 2018
1 parent 29ff214 commit 35b842d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 8 deletions.
4 changes: 4 additions & 0 deletions languages/default.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
posts: Posts
category: Category
categories: Categories
tag: Tag
tags: Tags
archives: Archives
about: About
recommendedPosts: Recommended Posts
readMore: Read more
toc: TOC
Expand Down
4 changes: 4 additions & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
posts: 文章
category: 分类
categories: 分类
tag: 标签
tags: 标签
archives: 归档
about: 关于
recommendedPosts: 推荐文章
readMore: 阅读更多
toc: 目录
Expand Down
48 changes: 43 additions & 5 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
<%
var title = page.title;
// tags, categories, about pages title
if (title == 'tags') {
title = __('tags');
} else if (title == 'categories') {
title = __('categories');
} else if (title == 'about') {
title = __('about');
}
// archives, category, tag pages title
if (is_archive()) {
title = __('archives');
if (is_month()) {
title += ': ' + page.year + '/' + page.month;
} else if (is_year()) {
title += ': ' + page.year;
}
} else if (is_category()) {
title = __('category') + ': ' + page.category;
} else if (is_tag()) {
title = __('tag') + ': ' + page.tag;
}
// final page title.
var pageTitle = title ? title + ' | ' + config.title : config.title;
// keywords.
var keyWords = config.keywords ? config.keywords : config.title;
keyWords = title ? title + ', ' + keyWords : keyWords;
// description.
var description = config.description ? config.description : config.title;
description = title ? title + ', ' + description : description;
%>

<head>
<meta charset="utf-8">
<meta name="keywords" content="<%= config.keywords %>, hexo-theme-matery">
<meta name="description" content="<%= config.description %>">
<meta name="keywords" content="<%= keyWords %>">
<meta name="description" content="<%= description %>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit|ie-stand|ie-comp">
<meta name="mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title><%= config.title %></title>
<link rel="icon" type="image/png" href="<%= theme.favicon %>">
<title><%= pageTitle %></title>
<link rel="icon" type="image/png" href="<%- theme.favicon %>">

<link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/libs/materialize/css/materialize.min.css">
Expand All @@ -21,4 +59,4 @@
<link rel="stylesheet" type="text/css" href="/css/my.css">

<script src="/libs/jquery/jquery-2.2.0.min.js"></script>
</head>
</head>
9 changes: 6 additions & 3 deletions layout/archive.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@
<% if (date(post.date, 'YYYY') != year) { %>
<% year = date(post.date, 'YYYY'); %>
<div class="cd-timeline-img year" data-aos="zoom-in-up">
<span><%- year %></span>
<a href="<%- url_for('/archives/' + year) %>"><%- year %></a>
</div>
<% } %>
<%# month. %>
<% if (date(post.date, 'YYYY-MM') != month) { %>
<% month = date(post.date, 'YYYY-MM'); %>
<%
month = date(post.date, 'YYYY-MM');
var m = date(post.date, 'MM')
%>
<div class="cd-timeline-img month" data-aos="zoom-in-up">
<span><%- date(post.date, 'MM') %></span>
<a href="<%- url_for('/archives/' + year + '/' + m) %>"><%- m %></a>
</div>
<% } %>
Expand Down
8 changes: 8 additions & 0 deletions source/css/matery.css
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,10 @@ table tr:nth-child(2n), thead {
font-weight: 600;
}

#cd-timeline .year a {
color: #fff;
}

#cd-timeline .month {
position: relative;
width: 60px;
Expand All @@ -989,6 +993,10 @@ table tr:nth-child(2n), thead {
font-weight: 600;
}

#cd-timeline .month a {
color: #fff;
}

#cd-timeline .day {
position: relative;
padding: 8px 10px;
Expand Down

0 comments on commit 35b842d

Please sign in to comment.