Hugo
Integrate ad blocker detection into your Hugo site for comprehensive visitor ad blocker tracking and revenue optimization
Installation
Target file:
layouts/_default/baseof.htmlQuick Integration
Add the following script tag to your HTML. Replace the data-key value with your actual API key.
Script Tag
<script src="https://cdn.antiblocker.io/ab.js" data-style="minimal" data-key="abk_****"></script>Complete Example
Here's a complete example showing where to place the script in your layouts/_default/baseof.html file:
layouts/_default/baseof.html
<!DOCTYPE html>
<html lang="{{ .Site.Language }}">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ .Title }}</title>
</head>
<body>
{{ block "main" . }}{{ end }}
<script src="https://cdn.antiblocker.io/ab.js" data-style="minimal" data-key="abk_****"></script>
</body>
</html>Configuration
Script Attributes
data-keyYour unique AntiBlocker API key (required)data-styleDisplay style - choose one of 6 variants: "classic", "dark", "educational", "friendly", "minimal", or "urgent"Implementation Notes
- Navigate to your Hugo project's 'layouts/_default' directory
- Open the 'baseof.html' file (the base template for all pages)
- Paste the script before the closing </body> tag
- All pages will automatically include the ad blocker detection
Best Practices
Performance
Place script before closing </body> tag. The script loads asynchronously and doesn't block page rendering.
Testing
Test integration in staging environment before deploying to production. Verify script loads correctly.
API Key
Obtain your unique API key from the AntiBlocker dashboard. Never share your key publicly.
Monitoring
Track detection rates and user responses through the AntiBlocker analytics dashboard.