为什么需要构建系统?
第一版网站是纯手写 HTML,每增加一篇文章就要:
- 修改 blog.html 添加条目
- 创建新的文章页面
- 更新首页的最新内容
- 检查所有链接是否正确
太麻烦了!
新方案
用 Python 写一个简单的构建脚本 build.py:
- 扫描
content/目录下的 markdown 文件 - 自动生成所有 HTML 页面
- 一键更新整个网站
核心逻辑
def build():
content = scan_content()
gen_index(content)
for module in MODULES:
gen_list_page(module, content[module])
gen_article_pages(module, content[module])
以上内容为AI生成的示例