Parse and read content of hugosite with golang and hugolib

Hello everyone,

I want to build a small indexer with bleve to index and search content in my hugosite. That’s work note mainly and I can’t use external service and elasticsearch take a lot of resource.

I want to build a small indexer with bleve and I need to parse my site. I’m mainly inspired with the code of fts5index (GitHub - fazalmajid/fts5index: SQLite FTS5-based search engine for Hugo pages) but the hugolib have change a lot since.

Have you an example of code for read all page of a designated hugosite or link to webpage with example ?

I wrote this but that don’t walk through pages

	osFs := hugofs.Os
	config, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{
		Fs:          osFs,
		Filename:    "config.toml",
		ConfigDir:   hugoPath,
		Environment: "development",
	if err != nil {
	base := config.GetFirstLanguageConfig().BaseConfig()
	base.WorkingDir = hugoPath

	// Config loaded
	fs := hugofs.NewFrom(osFs, base)
	sites, err := hugolib.NewHugoSites(deps.DepsCfg{
		Fs:      fs,
		Configs: config,
	err = sites.Build(hugolib.BuildCfg{SkipRender: true})
	if err != nil {
		log.Fatal("Could not render site:", err)
	if sites != nil && (sites.Pages() != nil) {
		for _, p := range sites.Pages() {
			if p != nil {


thanks for your help.

Best regards

When I check, the hugo site walking only works if I launch the program in the hugo directory. How can I config Hugo site from my code to give the hugopath directory in params.

Thanks for your help.