想要用 Flask 开发一个类似于 Hexo 的静态博客系统,可以本地跑 server 预览博客,最终生成 完整的 HTML 站点。支持更换主题。
文件结构如下:
/blog
server.py
generate.py
/templates
/theme1
layout.html
/theme2
layout.html
/static
/theme1
style.css
/theme2
style.css
比如在 theme1 的 layout.html 中连接 CSS 要这样做:
<link rel="stylesheet" type="text/css" href="static/theme1/style.css">
这样会给主题编写带来麻烦。有没有什么方法使得访问 CSS 更简单?最好是用简单一句 href="style.css" 就能够访问。(但是把 style.css 放在 theme1 文件夹里并没有用。)
最好耐心的去看看Flask 给出的docs
static-files