How to change json url each page

About Data-Driven Content


{{ $dataJ := getJSON “url” }}

I’d like to change json url each page.


{{ dataJ := getJSON "{{ .Param “json_url” }}" }}

is error.


Is there the way to change json url each page?


When I save edit, $ is disappeared.


doesn’t this work?

{{ $dataJ := getJSON ($.Param "json_url") }}

1 Like


doesn’t this work?

It works

Thank you for your quick reply!

1 Like

FYI, Sharing code in the forums. :slight_smile:

1 Like

Could you tell me how to change only part of json_url?

ex) YOUR_PLACE_ID,rating,formatted_phone_number&key=YOUR_API_KEY


My error is as follows.


{{ $dataJ := getJSON “{{ .Param “place_id” }}&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY” }}



{{ $dataJ := getJSON “” “{{ .Param “place_id” }}” “&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY” }}



{{ $dataJ := getJSON “ .Param “place_id” )&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY” }}



{{ $dataJ := getJSON “” “( .Param “place_id” )” “&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY” }}

it’s not clear to me what your error is, but you keep getting the {{ mixed up in the code.

I see this:

{{ $dataJ := getJSON “{{ .Param “place_id” }}&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY” }}

When you open the curly brackets, you can’t open again until you close it. Take a look at the documentation so you can become more familiar with how to set variables and build a single string out of two of them:

1 Like

Thank you for your quick reply.

{{ $dataJ := getJSON “{{ .Param “place_id” }}&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY” }}

It doen’t work.

I think that it is error in case there are multiple double quotes.


{{ dataJ := getJSON (.Param “json_url”) }}

It works when I try it with your advice.

The code is as follows.

{{ $urlPre := “” }}
{{ $urlAfter := “&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY” }}
{{ $dataJ := getJSON urlPre (.Param “place_id”) $urlAfter }}

I didn’t follow the problem closely, but, I’m not sure that you can nest template curly brace expressions? I think that does not work:

{{ some {{ the other thing }} thing }}

(Also, it’s probably a cut-and-paste artifact but I’ll mention just in case: using “smart” quotations causes trouble. They should be straight of course, in code.)