Pass parameters to GetRemote via options?

Hi everyone!
This is my first post here. I really love Hugo, so thanks to everyone who is involved.

I am wondering if it is possible to pass parameters to the URL used by .GetRemote via it’s options map?

This works fine:

{{ $url := print "https://" $cloudinary_key ":" $cloudinary_secret "@api.cloudinary.com/v1_1/" $cloudinary_name "/resources/search?expression=folder:" $cloudinary_folder "&max_results=" .number }}
{{ $resource := resources.GetRemote $url}}

But is is possible to do something like this:

{{ $url := print "https://" $cloudinary_key ":" $cloudinary_secret "@api.cloudinary.com/v1_1/" $cloudinary_name "/resources/search?expression=folder:" $cloudinary_folder }}
{{ $opts dict
    "max_results" "5"
}}
{{ $resource := resources.GetRemote $url $opts}}

The reason I ask is because I want to add a lot more parameters, which will make the URL long and difficult to handle and read.

Thanks!

The options are limited to the 3 listed here:

Tip:

  1. There’s printf
  2. You can split template commands in multiple lines.

So something ala this is pretty readable:

{{ $url := printf "https://%s?bar=%s&maxResults=%d"
        $foo
        $bar
        $maxResults
}}
2 Likes

And then there’s collections.Querify | Hugo

1 Like

Thank you very much for great help @bep
printf will be of great help.

And thank you for the great work you do with Hugo. I really appreciate it.

From a fellow norwegian.

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