Custom non-visible templates

To enable search on my blog, I’d like to create json files containing, for instance, post titles and URLs. Nothing complicated but I think it’s impossible right now.

A good feature, I think, would be to create custom templates like the RSS or sitemap which are in Hugo core. That way, I could define an output specific to my need and I guess it could be useful for other needs too.

Let me know if you need more information about this suggestion.

May contain some tips for a workaround.

Indeed, I read the whole topic with great interested and was thinking of doing this hack. But I think a way to create any template you want would be nice.

So, I tried this hack and it works indeed. But I have to change many things to forget about the son type I create, which is not ideal.

I hope someday we could have a better way. :slight_smile:

Well, I spoke to quickly : it does work to generate a JSON file, but now I have many problems with my blog. Every other post are not rendered the way they should, I guess it’s a type problem, but I have tried everything I could think of :

  • add post as the default type in config file
  • add an explicit post type to all my posts
  • even duplicate the single.html template in a “post” subfolder.

Nothing works, as you can see here : http://futur.voiretmanger.fr I have only the cover image and the title is deviated from the URL. I don’t understand why…

What should I do ? Thanks !

This pitfall is vaguely described in the topic above which I guess only makes this an option for the simplest blogs.

I guess the problem is that you have to make sure to filter out json … type != “json”

I did that for all the lists and indexes but why should I do the same for the single.html files ?

Envoyé de mon iPhone

Lets say it like this: I have not idea, and the above mentioned method is experimental and unsupported (hehe) … Hugo will eventual come with something clever.

I understand. I’ll check on the other post to see if there is a fix for me. If not, I guess I’ll follow the Grunt path, but I’d like to do everything with Hugo.

Let’s hope we’ll have something clever some day, then… :slight_smile:

To give more credit to my initial idea : I guess this ability to create custom templates could enable a sorte of infinite scrolling, or at least use AJAX to load pages when listing posts.

If you could define the pagination pages with a custom template instead of a standard one (so in my example, with just the list, no header or footer), I think it would be easy.