Skip to content

Commit b7a88a8

Browse files
committed
增加布局文件post.html
1 parent 19b42dd commit b7a88a8

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

‎_layouts/post.html‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
# 布局的前置元数据,可被Jekyll解析
3+
layout: default # 继承默认布局(minima主题核心布局,复用header/footer)
4+
---
5+
6+
<!-- 文章主体容器 -->
7+
<main class="post-content" aria-label="Content">
8+
<div class="wrapper">
9+
<!-- 文章头部信息:标题、日期、分类、标签 -->
10+
<article class="post h-entry" itemscope itemtype="http://schema.org/BlogPosting">
11+
<!-- 文章标题 -->
12+
<header class="post-header">
13+
<h1 class="post-title p-name" itemprop="name headline">
14+
{{ page.title | escape }} <!-- 渲染文章标题,escape防止XSS -->
15+
</h1>
16+
17+
<!-- 文章元信息:日期、分类、标签 -->
18+
<div class="post-meta">
19+
<!-- 发布日期 -->
20+
<time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">
21+
{{ page.date | date: "%Y年%m月%d日 %H:%M" }} <!-- 格式化日期为中文显示 -->
22+
</time>
23+
24+
<!-- 文章分类(如果有) -->
25+
{% if page.categories.size > 0 %}
26+
<span class="post-categories">
27+
分类:
28+
{% for category in page.categories %}
29+
<a href="{{ site.baseurl }}/categories/{{ category | slugify }}">{{ category }}</a>
30+
{% unless forloop.last %}, {% endunless %} <!-- 分类之间加逗号,最后一个不加 -->
31+
{% endfor %}
32+
</span>
33+
{% endif %}
34+
35+
<!-- 文章标签(如果有) -->
36+
{% if page.tags.size > 0 %}
37+
<span class="post-tags">
38+
标签:
39+
{% for tag in page.tags %}
40+
<a href="{{ site.baseurl }}/tags/{{ tag | slugify }}">{{ tag }}</a>
41+
{% unless forloop.last %}, {% endunless %}
42+
{% endfor %}
43+
</span>
44+
{% endif %}
45+
</div>
46+
</header>
47+
48+
<!-- 文章正文内容 -->
49+
<div class="post-content e-content" itemprop="articleBody">
50+
{{ content }} <!-- 渲染文章Markdown解析后的正文 -->
51+
</div>
52+
53+
<!-- 评论区(Utterances,对应_config.yml的配置) -->
54+
{% if page.comments != false %} <!-- 若文章未关闭评论则显示 -->
55+
<div class="post-comments">
56+
<h3>评论区</h3>
57+
<script src="https://utteranc.es/client.js"
58+
repo="{{ site.comments.utterances.repo }}"
59+
issue-term="pathname"
60+
label="comment"
61+
theme="github-light"
62+
crossorigin="anonymous"
63+
async>
64+
</script>
65+
</div>
66+
{% endif %}
67+
68+
<!-- 结构化数据标记(SEO优化) -->
69+
<meta itemprop="author" content="{{ site.author.name }}">
70+
<meta itemprop="description" content="{{ page.excerpt | default: site.description | strip_html | truncate: 160 }}">
71+
</article>
72+
</div>
73+
</main>

‎_posts/2026-02-02-第一篇博客.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ date: 2026-02-02 10:00:00 +0800
55
categories: [博客教程, GitHub Pages] # 精准分类(两级)
66
tags: [github, jekyll, 静态博客] # 细分标签
77
excerpt: "本文详细讲解从0到1搭建Jekyll+GitHub Pages博客,包括配置、部署、个性化全流程。" # 自定义摘要
8+
cover: "/asset/images/MiLog.jpg"
89
toc: true # 开启目录(后续实现)
910
---
1011

0 commit comments

Comments
 (0)