Skip to content

Commit cb6c25e

Browse files
committed
增加布局文件default.html
1 parent b7a88a8 commit cb6c25e

2 files changed

Lines changed: 110 additions & 1 deletion

File tree

‎_layouts/default.html‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<!DOCTYPE html>
2+
<!-- 声明文档类型为HTML5,指定语言为中文 -->
3+
<html lang="{{ site.lang | default: "zh-CN" }}">
4+
5+
<!-- HTML头部:包含元数据、样式、标题等,不显示在页面内容区 -->
6+
<head>
7+
<!-- 字符编码:必须设置为UTF-8,避免中文乱码 -->
8+
<meta charset="UTF-8">
9+
<!-- 响应式meta标签:适配手机/平板等移动端,核心的移动端适配配置 -->
10+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
11+
<!-- 页面标题:优先用页面自身的title,没有则用站点全局title -->
12+
<title>{{ page.title | default: site.title }}</title>
13+
<!-- 站点描述:用于SEO,提升搜索引擎收录效果 -->
14+
<meta name="description" content="{{ page.excerpt | default: site.description | strip_html | truncate: 160 }}">
15+
16+
<!-- 引入minima主题的默认样式(核心样式,包含基础布局、导航、页脚等样式) -->
17+
<link rel="stylesheet" href="{{ "/assets/css/style.css" | relative_url }}">
18+
<!-- 引入代码高亮的CSS文件(对应之前生成的syntax.css,实现代码高亮) -->
19+
<link rel="stylesheet" href="{{ "/assets/css/syntax.css" | relative_url }}">
20+
21+
<!-- 引入浏览器图标(favicon):可选,若有则替换路径,无则可注释 -->
22+
<link rel="icon" href="{{ "/assets/favicon.ico" | relative_url }}" type="image/x-icon">
23+
24+
<!-- RSS订阅链接:Jekyll自动生成,方便用户订阅博客更新 -->
25+
{% feed_meta %}
26+
<!-- SEO优化标签:minima主题内置,提升搜索引擎友好度 -->
27+
{% seo %}
28+
</head>
29+
30+
<!-- HTML主体:页面可见的内容区域 -->
31+
<body>
32+
<!-- 页面头部/导航栏:复用minima主题的header组件 -->
33+
<header class="site-header" role="banner">
34+
<div class="wrapper">
35+
<!-- 博客标题:点击跳转到首页 -->
36+
<a class="site-title" rel="author" href="{{ "/" | relative_url }}">{{ site.title | escape }}</a>
37+
38+
<!-- 导航菜单:仅当配置了导航链接时显示 -->
39+
{%- assign default_paths = site.pages | map: "path" -%}
40+
{%- assign page_paths = site.header_pages | default: default_paths -%}
41+
{%- if page_paths -%}
42+
<nav class="site-nav">
43+
<input type="checkbox" id="nav-trigger" class="nav-trigger">
44+
<label for="nav-trigger">
45+
<span class="menu-icon">
46+
<svg viewBox="0 0 18 15" width="18px" height="15px">
47+
<path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
48+
</svg>
49+
</span>
50+
</label>
51+
52+
<div class="trigger">
53+
<!-- 遍历配置的导航页面,生成导航链接(如about页) -->
54+
{%- for path in page_paths -%}
55+
{%- assign my_page = site.pages | where: "path", path | first -%}
56+
{%- if my_page.title -%}
57+
<a class="page-link" href="{{ my_page.url | relative_url }}">{{ my_page.title | escape }}</a>
58+
{%- endif -%}
59+
{%- endfor -%}
60+
</div>
61+
</nav>
62+
{%- endif -%}
63+
</div>
64+
</header>
65+
66+
<!-- 页面主要内容区:{{ content }} 是占位符,会被具体页面/文章的内容替换 -->
67+
<main class="page-content" aria-label="Content">
68+
<div class="wrapper">
69+
{{ content }}
70+
</div>
71+
</main>
72+
73+
<!-- 页面页脚:复用minima主题的footer组件 -->
74+
<footer class="site-footer h-card">
75+
<data class="u-url" href="{{ "/" | relative_url }}"></data>
76+
77+
<div class="wrapper">
78+
<!-- 页脚标题:默认用站点标题 -->
79+
<h2 class="footer-heading">{{ site.title | escape }}</h2>
80+
81+
<div class="footer-col-wrapper">
82+
<div class="footer-col footer-col-1">
83+
<!-- 社交链接:从_config.yml中读取配置的社交账号 -->
84+
<ul class="contact-list">
85+
<li class="p-name">
86+
{%- if site.author -%}
87+
{{ site.author | escape }}
88+
{%- endif -%}
89+
</li>
90+
{%- if site.email -%}
91+
<li><a class="u-email" href="mailto:{{ site.email }}">{{ site.email }}</a></li>
92+
{%- endif -%}
93+
</ul>
94+
</div>
95+
96+
<!-- 站点简介:从_config.yml中读取description -->
97+
<div class="footer-col footer-col-2">
98+
{%- include social.html -%}
99+
</div>
100+
101+
<div class="footer-col footer-col-3">
102+
<p>{{- site.description | escape -}}</p>
103+
</div>
104+
</div>
105+
</div>
106+
</footer>
107+
108+
</body>
109+
</html>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ toc: true # 开启目录(后续实现)
2525
3. 通过GitHub Actions自动部署。
2626

2727
### 代码示例
28+
### 本地启动Jekyll服务
2829
```bash
29-
# 本地启动Jekyll服务
3030
bundle exec jekyll serve

0 commit comments

Comments
 (0)