Skip to main content

Netlify: Loading fonts from Git-LFS

Summary

Learn how to enable Netlify to load fonts and other assets from Git Large File Storage (LFS). Fixes, e.g. downloadable font: rejected by sanitizer error.

Netlify retires Git-LFS support #

As of September 1, 2023 the Large Media feature is deprecated. Sites already using the feature will be unaffected at this time: Large Media will continue to work on these sites as usual. Source

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, 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.

GIT_LFS variables are not controllable via the netlify.toml file.

Configuration via netlify.toml does not work #

[build.environment]
  GIT_LFS_ENABLED = "true"
  GIT_LFS_FETCH_INCLUDE = "*.eot, *.woff, *.woff2"

Further readings #

Sources and recommended, further resources on the topic:

Author

Jonas Jared Jacek • J15k

Jonas Jared Jacek (J15k)

Jonas works as project manager, web designer, and web developer since 2001. On top of that, he is a Linux system administrator with a broad interest in things related to programming, architecture, and design. See: https://www.j15k.com/

License

License: Netlify: Loading fonts from Git-LFS by Jonas Jared Jacek is licensed under CC BY-SA 4.0.

This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:

<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/instructions/netlify-loading-git-lfs-fonts">Netlify: Loading fonts from Git-LFS</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>

For more information see the DITig legal page.


“Obey standards unless you've a darn good reason.”

Alan Cooper , Software designer and programmerAbout Face, - IT quotes