cecil / theme-netlify
Cecil 组件主题 Netlify
资助包维护!
ArnaudLigny
Open Collective
2.0.1
2024-03-25 10:42 UTC
Requires
- cecil/theme-installer: ^1.4|^2.0
README
为 Cecil 提供支持 Netlify 的 _redirects
和 _header
组件主题。
安装后无需任何配置,此组件主题将生成
- 一个
_redirects
文件,包含由 Cecil(自动创建或通过redirect
前端变量手动创建的 HTML 重定向 - 一个
_header
文件,包含关于安全和资产缓存控制的最佳实践
安装
composer require cecil/theme-netlify
或者 下载最新存档 并将其内容解压缩到
themes/netlify
。
用法
在您的 config.yml
的 theme
部分中添加 netlify
theme: - netlify
添加重定向
netlify: redirects: - from: https://xxxxxx/* to: https://xxxxxx/:splat status: 301 # optional force: true # optional
有关详细信息,请参阅 Netlify 文档。
将主页重定向到用户语言版本
netlify: redirect_by_language: true # false by default
为每种可用的语言(除默认语言外)生成以下重定向
/ /<language-code>/ 302! Language=<language-code>
示例
/ /fr/ 302! Language=fr
语言可以指定在 cookie
nf_lang
中,因此您可以使用 JavaScript 覆盖默认行为(例如,如果有一个语言下拉选择器)。