Template:Query page

A template for queries stored on a dedicated wiki page. Store the query using this template, and it can be transcluded into other wiki pages into a variety of formats.


Two examples have been set up at Template:query page/sandbox and Template:query page/sandbox 2. See their talk pages for examples of the transclusion styles.

Query page usageEdit

Minimal example:

{{query page
|title=Some title
|query=SELECT (1 AS ?example) WHERE {}

Typical example:

{{query page
|title=Some title
|query=SELECT (1 AS ?example) WHERE {}

For the full list of parameters, see the template data.

Note that the above inputboxes don’t add any prefix to the title. If you’re planning to use this template regularly, you probably want to copy them to some subpage of your user page and add an appropriate prefix parameter there. See the inputbox at User:TweetsFactsAndQueries/Queries for an example of this.

Transclusion usageEdit

Suppose you want to use/reference the query that’s stored at User:TweetsFactsAndQueries/Queries/EGOT winners.

For a {{SPARQL}} block:

{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=SPARQL}}

For a link to the query:

{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=link}}

For the URL to the embed page:

{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=url embed}}

For the plain query text, typically used in another template (e. g. {{Wikidata list}}):

{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=query}}

Full list of styles:

Note that you can’t transclude queries like this into Wikidata:SPARQL query service/queries/examples – due to the way the Query Service UI loads the example queries, they won’t show up in the list of examples there, even though they’ll look identical to other queries on the wiki page itself.

Template dataEdit

A template for queries stored on a dedicated wiki page

Template parameters


The style with which this query should be transcluded. Should always be passed through.


The title used for linking to this query. Often related to the base page name. Can use the LangSwitch template to specify titles in different languages.


The query itself. Escape any vertical bars as {{!}}.

original tweet URLoriginal_tweet_url

The URL of a Twitter tweet where this query was originally published.

original toot URLoriginal_toot_url

The URL of a Mastodon toot where this query was originally published.

header wikitext (after “original…”)header_wikitext_after_original

Additional wikitext to append after the “originally published…” text from the tweet/toot URLs.

header wikitext paragraphheader_wikitext_paragraph

Additional wikitext to append as a separate paragraph to the header.

footer wikitextfooter_wikitext

A footer after the query.