What do embedded templates call?

I had made a separate post here on overriding ref shortcode, but I would like to formulate it more generally:

Where do I look if I want to explore further what these embedded templates do?

I suppose this will be handled further by Go code, but I just cannot easily find it. So, what exactly does the e.g. ref.html refer to by its own {{ ref . .Params }} call?

I got to dig out shortcode.go, but I might be off.

Is there any high-level developer docs on the architecture of Hugo, other than right away becoming a full-fledged contributor? :slight_smile:

When you call the ref shortcode from a template, it calls the ref template function, passing the current context and the map of params that you passed in.

Thanks for the answer! Yes, this one I understood from e.g. how themes are put together, but when the embedded one does it, what exactly gets executed, where?

Is the template.go the right code to start looking at?

EDIT Sorry, probably this tplimpl/template.go one is the correct one I should start with.

An embedded shortcode is just like a custom shortcode. Think of it as being invisibly mounted to the layouts/shortcodes directory. That’s why you can override an embedded shortcode by creating one of the same name in the layouts/shortcodes directory.

1 Like

Thanks for the reply, I understand the embedded shortcodes are the “last in line”, I just got myself into a circle thinking of:

When you call the ref shortcode from a template, it calls the ref template function

The template functions as described in the docs do not show ref, so I went looking for its implementation.

I basically got lost in looking for what exactly gets executed when template function like ref is called, as in, the actual code.

I think I have to examine more of how Hugo works, but that’s my problem.

dunno if that will bring you closer…you will have to learn go and the hugo internals.

the template function is documented here urls.Ref. this decribe how to use it within go template code.

the function itself is implemented here:hugo/tpl/urls/urls.go at master · gohugoio/hugo · GitHub.

2 Likes

This DOES help! Thanks a lot, @irkode! I completely overlooked the aliases and so did not realise it’s one and the same as urls.Ref. Now that makes more sense and I can go explore urls.RefLinker call. :slight_smile:

you will have to learn go and the hugo internals

That’s not an issue, I just wanted to have a quick look for now “looking backwards” without going to trace all the calls of the site being built.

Cheers!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.