Hugo Integration
Add Ask0 to your Hugo static site. Step-by-step guide for enhancing Hugo-built websites with AI-powered search and chat.
Add Ask0 to your Hugo static site or documentation.
Installation
Partial Template
Create a partial template for the widget:
<script
src="https://assets.ask0.ai/scripts/ask.js"
data-project-id="{{ .Site.Params.ask0.projectId }}"
data-position="{{ .Site.Params.ask0.position | default "bottom-right" }}"
data-theme="{{ .Site.Params.ask0.theme | default "auto" }}"
async
></script>Include in Layout
Add to your base layout:
<!DOCTYPE html>
<html lang="{{ .Site.Language.Lang }}">
<head>
<meta charset="UTF-8">
<title>{{ .Title }}</title>
</head>
<body>
{{ block "main" . }}{{ end }}
{{ partial "ask0.html" . }}
</body>
</html>Configuration
Add to your Hugo config:
[params.ask0]
projectId = "YOUR_PROJECT_ID"
position = "bottom-right"
theme = "auto"Or in YAML:
params:
ask0:
projectId: YOUR_PROJECT_ID
position: bottom-right
theme: autoDocsy Theme
For Hugo Docsy documentation theme:
{{ if .Site.Params.ask0.enabled }}
<script
src="https://assets.ask0.ai/scripts/ask.js"
data-project-id="{{ .Site.Params.ask0.projectId }}"
async
></script>
{{ end }}Configuration:
[params.ask0]
enabled = true
projectId = "YOUR_PROJECT_ID"Ananke Theme
For Hugo Ananke theme:
<script
src="https://assets.ask0.ai/scripts/ask.js"
data-project-id="{{ getenv "HUGO_ASK0_PROJECT_ID" }}"
async
></script>Conditional Loading
Load only on specific sections:
{{ if or (eq .Section "docs") (eq .Section "blog") }}
<script
src="https://assets.ask0.ai/scripts/ask.js"
data-project-id="{{ .Site.Params.ask0.projectId }}"
async
></script>
{{ end }}Environment Variables
Use environment variables for different environments:
{{ $projectId := getenv "HUGO_ASK0_PROJECT_ID" }}
{{ if not $projectId }}
{{ $projectId = .Site.Params.ask0.projectId }}
{{ end }}
<script
src="https://assets.ask0.ai/scripts/ask.js"
data-project-id="{{ $projectId }}"
async
></script>Hugo Tips:
- Use partials for reusable components
- Store config in
config.tomlorconfig.yaml - Use environment variables for deployment
- Works with all Hugo themes
- Compatible with Hugo Modules
Next Steps
Sphinx Integration
Enhance your Sphinx documentation with Ask0's AI assistant. Learn how to integrate intelligent search and chat into your Python documentation built with Sphinx.
Gatsby Integration
Integrate Ask0's AI search and chat into your Gatsby site. Add intelligent documentation assistance to Gatsby-based React apps.