Configuring Netlify to serve files from Git-LFS [1] can lead to frustration [2] as solutions are not easily findable.
Set environment variables
Setting the correct environment variables in Netlify, fixes the obscure downloadable font: rejected by sanitizer
error. The files exist on the host and can be downloaded but can not be referenced in e.g. .css
files.
Configuration in web interface
In your Netlify account [3], go to Build & deploy → Environment and click on Edit variables to adjust the settings that control the environment your site builds in and/or gets deployed to. Set the following two environment variables and values:
GIT_LFS_ENABLED = true
GIT_LFS_FETCH_INCLUDE = *.eot, *.woff, *.woff2
Configuration in netlify.toml
In addition to using the Netlify web interface to configure environment variables, you can also configure some settings in a netlify.toml
file stored in the root of your site repository.
Unfortunately, GIT environment variables are needed before cloning the repository. Thus, GIT_LFS variables are not controllable via the netlify.toml
file.[5]
The following code example does not work:
[build.environment]
GIT_LFS_ENABLED = "true"
GIT_LFS_FETCH_INCLUDE = "*.eot, *.woff, *.woff2"
Abbreviations
- LFS
- Large File Storage