Add Plausible Analytics support

- Add plausible configuration option in _config.yml
- Create head-custom-plausible-analytics.html include file
- Update head-custom.html to include Plausible Analytics
- Support for self-hosted Plausible via plausible_script_url option

Users can now configure Plausible Analytics similarly to Google Analytics:
- Set plausible: yourdomain.com in _config.yml
- Optionally set plausible_script_url for self-hosted instances
This commit is contained in:
Claude
2025-11-06 06:55:43 +00:00
parent b028d46f89
commit 241dcdcb10
3 changed files with 9 additions and 0 deletions

View File

@@ -2,4 +2,6 @@ title: Hacker theme
description: Hacker is a theme for GitHub Pages.
show_downloads: true
google_analytics:
plausible:
# plausible_script_url: https://plausible.io/js/script.js # Optional: for self-hosted Plausible instances
theme: jekyll-theme-hacker

View File

@@ -0,0 +1,4 @@
{% if site.plausible %}
<!-- Plausible Analytics -->
<script defer data-domain="{{ site.plausible }}" src="{% if site.plausible_script_url %}{{ site.plausible_script_url }}{% else %}https://plausible.io/js/script.js{% endif %}"></script>
{% endif %}

View File

@@ -6,6 +6,9 @@
<!-- Setup Google Analytics -->
{% include head-custom-google-analytics.html %}
<!-- Setup Plausible Analytics -->
{% include head-custom-plausible-analytics.html %}
<!-- You can set your favicon here -->
<!-- link rel="shortcut icon" type="image/x-icon" href="{{ '/favicon.ico' | relative_url }}" -->