Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions layouts/_partials/components/analytics/matomo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
https://developer.matomo.org/guides/tracking-javascript-guide
*/ -}}

{{- with .Site.Params.analytics.matomo -}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also checked at

{{- if .Site.Params.analytics.matomo -}}

I guess we don't need both?

Copy link
Contributor Author

@ldez ldez Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 2 different things:

  • The if is purely conditional and doesn't change the scope of .
  • The with is conditional, but it also changes the scope of .

IMHO, it's better to have a larger scope at the global partial level (because it's easier to override), and inside the partial have a restricted scope for readability and maintenance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 If someone wants to override (to a specific analytics), he can either override layouts/_partials/components/analytics/analytics.html or add an element inside layouts/_partials/custom/head-end.html.

So I think I will use with.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 2 different things:

  • The if is purely conditional and doesn't change the scope of .
  • The with is conditional, but it also changes the scope of .

IMHO, it's better to have a larger scope at the global partial level (because it's easier to override), and inside the partial have a restricted scope for readability and maintenance.

I see, that makes more sense, I think I’d actually prefer giving the partial a broader scope now 🤔


{{- if not .serverURL }}
{{- errorf "Missing Matomo 'serverURL' configuration. See https://imfing.github.io/hextra/versions/latest/docs/guide/configuration/#matomo-analytics" -}}
{{- end -}}

{{- if not .websiteID }}
{{- errorf "Missing Matomo 'websiteID' configuration. See https://imfing.github.io/hextra/versions/latest/docs/guide/configuration/#matomo-analytics" -}}
{{- end -}}

<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
Expand All @@ -17,3 +27,5 @@
})();
</script>
<!-- End Matomo Code -->

{{- end -}}
4 changes: 2 additions & 2 deletions layouts/_partials/components/analytics/umami.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
{{- with .Site.Params.analytics.umami -}}

{{- if not .serverURL }}
{{- errorf "Missing Umami 'serverURL' configuration. See TODO" -}}
{{- errorf "Missing Umami 'serverURL' configuration. See https://imfing.github.io/hextra/versions/latest/docs/guide/configuration/#umami-analytics" -}}
{{- end -}}

{{- if not .websiteID }}
{{- errorf "Missing Umami 'websiteID' configuration. See TODO" -}}
{{- errorf "Missing Umami 'websiteID' configuration. See https://imfing.github.io/hextra/versions/latest/docs/guide/configuration/#umami-analytics" -}}
{{- end -}}

{{- $attributes := newScratch -}}
Expand Down