Add Dark Mode to Your Website

Add Dark Mode to Your Website

Add dark mode to your website using DarkReader. This is a simple way to add dark mode to your website.

1
2
3
4
5
6
7
8
9
{% if jekyll.environment == 'production' -%}
<!-- dark theme using DarkReader -->
<script src="//unpkg.com/darkreader@4.9.40/darkreader.js"></script>
<script type="text/javascript">
DarkReader.setFetchMethod(window.fetch); // Fix to remedy CORS errors in chrome console
//DarkReader.enable();
DarkReader.auto( {brightness: 100, contrast: 90, sepia: 10} );
</script>
{%- endif %}


Reference:
reference the implementation from link

Author

AlanZeng

Posted on

2024-08-16

Updated on

2026-01-19

Licensed under

Comments