Files
pulse/content/integrations/hugo.mdx
Usman Baig 627613dc13 fix: code blocks rendering + consistent styling with ciphera-website /learn
- Convert MDX CodeBlock components to standard markdown code fences
- Add rehype-mdx-code-props to pass filename meta to code components
- Custom pre/code MDX components map fences to CodeBlock
- Add brand color badges (product + category) matching /learn layout
- Match prose styling: orange inline code, orange links, white strong
- Remove brand color background glow (not in /learn)
2026-03-29 01:01:56 +01:00

49 lines
1.2 KiB
Plaintext

---
title: "Hugo"
description: "Add Pulse analytics to your Hugo site via a partial or base template."
category: "ssg"
brandColor: "#FF4088"
officialUrl: "https://gohugo.io/documentation"
relatedIds: ["jekyll", "eleventy", "astro"]
date: "2026-03-28"
---
Add the Pulse script via a Hugo partial or directly in your base template.
---
## Method 1: Create a partial
Create an analytics partial with a production guard using Hugo's `.Site.IsServer` flag.
```html filename="layouts/partials/analytics.html"
{{ if not .Site.IsServer }}
<script
defer
data-domain="your-site.com"
src="https://pulse.ciphera.net/script.js"
></script>
{{ end }}
```
## Method 2: Include the partial in your base layout
Add the partial to your `baseof.html` layout.
```html filename="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">
{{ partial "analytics.html" . }}
<title>{{ .Title }}</title>
</head>
<body>
{{ block "main" . }}{{ end }}
</body>
</html>
```
For more details, see the [Hugo partials docs](https://gohugo.io/templates/partials/).