认识安企CMS-系统和模板文件结构
2026/7/6 3:41:29
网站开发
了解安企CMS安装后的完整目录结构掌握主程序、配置文件、模板目录、附件目录、运行时数据等每个关键目录和文件的具体作用方便后续日常维护和二次开发。安企CMS 安装后的完整目录结构概览带你了解每个目录和文件的用途。一、顶层目录结构anqicms/ # 网站根目录 ├── anqicms # 主程序可执行文件Linux/Mac ├── anqicms.exe # 主程序可执行文件Windows ├── config.json # 配置文件端口、数据库、站点名称等 ├── config.sample.json # 配置示例文件首次启动自动复制为 config.json ├── template/ # 模板目录重点见下文详解 ├── public/ # Web 根目录Nginx 运行目录见下文详解 ├── data/ # 数据目录 │ ├── backup/ # 数据库备份文件 │ ├── cert/ # 支付证书文件 │ └── logs/ # 运行日志 ├── cache/ # 缓存目录文件缓存、模板缓存 ├── locales/ # 国际化语言包 │ ├── zh-CN/ # 简体中文 │ ├── en-US/ # 英文 │ ├── ja-JP/ # 日文 │ ├── ru-RU/ # 俄文 │ ├── pt-BR/ # 葡萄牙文 │ ├── id-ID/ # 印尼文 │ └── bn-BD/ # 孟加拉文 ├── dictionary.txt # 中文分词词典全文搜索用 ├── CHANGELOG.md # 版本更新日志 ├── README.md # 项目说明 └── License # AGPL-3.0 开源协议注意仅从编译包release 模式解压后看到的是运行必需目录。从 GitHub 克隆源码目录包含更多开发相关文件controller/、model/、go.mod等生产环境部署时可删除。二、模板目录template/详解template/是安企CMS 的模板根目录每套模板独立一个子目录。系统通过config.json识别和加载模板。2.1 模板配置文件 config.json每套模板目录下都包含config.json默认会自动生成可手动修改。内容格式如下{name:默认模板,package:default,version:1.0,description:系统默认模板,author:安企CMS,homepage:,created:2022-05-10 22:29:00,template_type:0,status:0}字段类型必填说明namestring否模板显示名称留空自动取目录名packagestring否模板文件夹名仅支持英文字母和数字versionstring否模板版本号descriptionstring否模板介绍说明authorstring否模板作者homepagestring否作者网站地址createdstring否创建时间格式2006-01-02 15:04:05template_typeint否0自适应1代码适配2电脑手机statusint否0未启用1启用中只能有一套为 12.2 模板文件组织模式安企CMS 默认支持文件夹模式组织方式。文件夹模式template/mytemplate/ ├── config.json # 模板配置文件必须 ├── base.html # 公共基础模板页头/页脚等公共布局 ├── partial/ # 代码片段目录 │ ├── header.html # 页头导航、Logo │ ├── footer.html # 页脚版权、备案号 │ ├── sidebar.html # 侧边栏 │ └── pagination.html # 分页组件 │ ├── index/ │ └── index.html # 首页 │ ├── archive/ # 文章模型默认模型 tablearchive │ ├── index.html # 文章模型首页 │ ├── list.html # 文章列表页 │ ├── list-{分类ID}.html # 特定分类的列表页如 list-5.html │ ├── detail.html # 文章详情页 │ └── detail-{文档ID}.html # 特定文档的详情页如 detail-1.html │ ├── product/ # 产品模型tableproduct │ ├── index.html # 产品模型首页 │ ├── list.html # 产品列表页 │ ├── list-{分类ID}.html # 特定产品分类列表页 │ ├── detail.html # 产品详情页 │ └── detail-{文档ID}.html # 特定产品详情页 │ ├── page/ # 单页面 │ ├── detail.html # 单页面详情页 │ └── {Url别名}.html # 特定单页面如 detail-about.html │ ├── tag/ │ ├── index.html # 标签首页 │ └── list.html # 标签文档列表页 │ ├── comment/ │ └── list.html # 评论列表页 │ ├── guestbook/ │ └── index.html # 在线留言页 │ ├── search/ │ └── index.html # 搜索页 │ ├── errors/ │ ├── 404.html # 404 错误页 │ ├── 500.html # 500 错误页 │ └── close.html # 站点关闭提示页 │ └── mobile/ # 手机端模板目录template_type2 时使用 ├── index/ │ └── index.html ├── archive/ │ ├── list.html │ └── detail.html └── ... # 结构同 PC 端2.3 模板文件与页面匹配规则| 页面类型 | 文件夹模式路径 ||----------|---------------|---------------|| 首页 |index/index.html|| 模型首页 |{模型table}/index.html|| 文档列表 |{模型table}/list.html|| 文档详情 |{模型table}/detail.html|| 分类列表独立模板 |{模型table}/list-{分类ID}.html|| 文档详情独立模板 |{模型table}/detail-{文档ID}.html|| 单页面 |page/detail.html|| 单页面独立模板 |page/{Url别名}.html|| 标签首页 |tag/index.html|| 标签列表 |tag/list.html|| 评论列表 |comment/list.html|| 留言页面 |guestbook/index.html|| 搜索页 |search/index.html|| 404 错误 |errors/404.html|| 500 错误 |errors/500.html|| 站点关闭 |errors/close.html|{模型table}是内容模型中定义的table_name默认文章模型为archive产品模型为product。2.4 模板命名规范规则说明文件编码必须使用UTF-8无 BOM否则页面乱码文件后缀所有模板文件使用.html后缀变量命名使用驼峰命名首字母大写如{{archive.Title}}自定义模板detail-{ID}.html和list-{ID}.html可为特定文档/分类设置独立模板三、Web 根目录public/详解public/是 Nginx 反向代理时必须指向的 Web 根目录包含了所有可直接访问的静态资源。anqicms/public/ ├── static/ # 静态资源目录 │ ├── default/ # 模板对应文件夹 │ │ ├── css/ # 模板样式文件 │ │ │ ├── style.css │ │ │ └── ... │ │ ├── js/ # JavaScript 文件 │ │ │ ├── main.js │ │ │ └── ... │ │ └── images/ # 图片资源 │ │ ├── logo.png │ │ └── ... ├── uploads/ # 上传资源目录用户上传的图片/文件 │ ├── images/ # 按年/月自动归档 │ │ ├── 2026/ │ │ │ ├── 01/ │ │ │ ├── 02/ │ │ │ └── ... │ │ └── ... ├── robots.txt # 爬虫规则后台可配置 ├── sitemap.xml # Sitemap 索引文件自动生成 └── LLMs.txt # AI 索引文件后台可配置四、各目录/文件在生产环境的必要性目录/文件生产必需说明anqicms可执行文件✅ 必需程序本身没有它无法运行config.json✅ 必需配置文件没有它程序不知道端口和数据库template/✅ 必需模板文件没有模板前台无法显示public/✅ 必需Web 根目录Nginx 的指向目标data/✅ 必需运行数据备份、缓存、日志cache/✅ 必需缓存目录locales/✅ 必需多语言包dictionary.txt✅ 必需中文分词词典CHANGELOG.md、README.md、License❌ 可删除纯文档文件五、安全提醒public/ 的根目录配置务必确保 Nginx 配置中的root指向public/目录而不是anqicms/根目录# ❌ 错误 —— 用户可直接访问 config.json、template/ 等敏感文件 root /data/wwwroot/anqicms; # ✅ 正确 —— 外部只能访问 public/ 下的资源 root /data/wwwroot/anqicms/public;