How to add Asklet to Hugo
Show Asklet after every Hugo post with one partial in your single page template.
Steps
- 01
Copy your snippet
In Asklet, open your website and click Copy website snippet at the top.
- 02
Create a partial
Save the snippet as layouts/_partials/feedback.html in your site (layouts/partials/ before Hugo 0.146), not in the theme folder, so theme updates keep it.
- 03
Include it after the content
Copy your theme's single page template to the same path in your own layouts folder: layouts/single.html in Hugo 0.146 and later, layouts/_default/single.html in older sites and themes. Then add {{ partial "feedback.html" . }} after {{ .Content }}.
- 04
Check it on your live site
Open a published post on a domain you listed in Asklet and answer the survey. To keep your own test answers out of the results, add the page in Asklet first: new pages start in test mode.
<iframe src="https://asklet.io/embed/s/<your-site>" title="Article feedback" width="100%" height="480" loading="lazy" referrerpolicy="unsafe-url" style="border:0"></iframe>- Keep referrerpolicy="unsafe-url" on the iframe - Asklet uses it to know which page the reader is on, so the right survey appears.
- Posts live at addresses such as /posts/my-post/, so /posts/* covers them all.
- To show the survey in one section only, wrap the partial in {{ if eq .Section "posts" }} … {{ end }}.
Troubleshooting
The snippet disappears when pasted into Markdown
Hugo's Markdown renderer leaves out raw HTML unless markup.goldmark.renderer.unsafe is true. Use the partial instead of pasting the snippet into a post.
Common questions
Do I need a shortcode?
Only to place the survey by hand inside one post. For every post, the partial in your template is simpler.
Other platforms
All integrationsGet your first answers today.
Set-up takes a few minutes, and the free plan covers one website or app.
Start freeFree plan, no card needed.