Skip to content

The Netlify component theme for Cecil provides support of Netlify's _redirects and _header.

License

Notifications You must be signed in to change notification settings

Cecilapp/theme-netlify

Repository files navigation

Netlify component theme

The Netlify component theme for Cecil provides support of Netlify's _redirects and _header.

After installation and without any configuration, this component theme generate:

  1. a _redirects file containing HTML's redirections created by Cecil (automatic or created manually with the redirect front matter variable)
  2. a _headers file containg HTTP headers created by Cecil (generated from headers' configuration)

Installation

composer require cecil/theme-netlify

Or download the latest archive and uncompress its content in themes/netlify.

Usage

Add netlify in the theme section of your site configuration:

theme:
  - netlify

Add redirections

netlify:
  redirects:
    - from: https://xxxxxx/*
      to: https://xxxxxx/:splat
      status: 301 # optional
      force: true # optional

Refer to Netlify documentation for details.

Redirect home page to the user language version

netlify:
  redirect_by_language: true # false by default

It generate the following redirect for each available language (other than the default):

/  /<language-code>/    302!    Language=<language-code>

Example:

/  /fr/    302!    Language=fr

The language can be specified in the cookie nf_lang, so you can override the default behavior with JavaScript (in case of a language dropdown selector for example).

Add headers

headers:
  - path: <path> # Relative path, prefixed with a slash. Support "*" wildcard.
    headers:
      - key: <key>
        value: "<value>"

Document: https://cecil.app/documentation/configuration/#headers.