RawQuery returns the query string. You can replace RawQuery with Host, Scheme, Fragment, String, or Query.Get “parameter”.
I’d really like to be able to retrieve a particular query parameter, but all of the following make Caddy give a 500 Internal Server Error when I request a URL with the format mywebsite.com/page?parameter=something:
{{.URL.Query.Get "parameter"}}
{{.URL.Query.Get("parameter")}}
{{.URL.Query.Get["parameter"]}}
{{.URL.Query["parameter"]}}
When I print out the value for just {{.URL.Query}} I get map[parameter:[something]], but it’s not clear to me where to go from here.
I’m sure the root problem is I don’t know Go at all, but I can’t think of any other things to try. Could someone please provide some clarification on the syntax here?
@matt Thanks for the response! With the information in your post, I was able to track down the real issue. My template is getting compiled to HTML before being used to render my Markdown files. During the compilation process, the quotes around the parameter name were getting converted to “smart” quotes. Explicitly telling the compiler to render them as regular double-quotes fixed everything. But before that, it was hard to tell what was wrong even staring at the compiled version because the quotes didn’t look that different…