编辑 config.json 文件中的配置参数, 如果没有则自行创建
{
"template": "模板文件目录地址",
"views": "网页文件目录地址",
"static": "静态文件目录地址",
"Port": "服务端口"
}
除 html 文件外的资源文件, 比如 css, js 等文件
template 使用教程
配置公共文件, 比如配置统一的头部, 统一的尾部等内容。
common
head.html
layout
index.html
- define 定义模板名称
- template 导入公共文件
{{ define "common/head.html" }}
<title>{{ .title }}</title>
{{ end }}
{{ define "layout/index.html" }}
<!DOCTYPE html>
<html lang="en">
<head>
{{ template "common/head.html" . }}
</head>
<body>
{{ .content }}
</body>
</html>
{{ end }}
所有 html 文件
html 文件中的第一行为配置信息
- title 网页标题
- layout 指定 template 中的模板名称
<!--{ "title": "XXX", "layout": "layout/index.html" }-->
<div>
<p>hello world</p>
</div>