Embedding into Jekyll
To feed the output of doc2go into Jekyll, you need at least the following:
- enable embedded mode
- add front matter to each generated file
- generate pages into your Jekyll directory
So if your Jekyll website is a subdirectory inside your project with a layout similar to the following:
Project root
|- go.mod
|- foo.go
'- docs/
|- _config.yml
|- _posts/
'- index.md
Add a front matter template to the docs directory:
cat > docs/frontmatter.tmpl << EOF
---
title: "{{ with .Name }}{{ . }}{{ else }}Reference{{ end }}"
layout: default
render_with_liquid: false
---
EOF
And run this command from the project root:
doc2go -embed -out docs/api -frontmatter docs/frontmatter.tmpl ./...
This will generate your API reference under an /api
path
on your website.
The front matter template above specifies that your website
should use the package or binary name as the page title,
or the directory name if it’s not a Go package.
Additionally, it instructs Jekyll’s templating system
(Liquid)
to ignore these pages—this prevents Liquid
from interpreting occurences of {{
, }}
, {%
, and %}
in your documentation as Liquid filters or tags.
See Adding front matter to write your own templates.