URL Template is a way to specify a URL that includes parameters that must be substituted before the URL is resolved. The syntax is usually to enclose the parameter in Braces ({example}). The agreement is for a parameter to not Be Percent encoded UNLESS it follows a Question Mark (?).


  • http://example.com/people/{firstName}-{lastName}/SSN
  • http://example.com/query?firstName={firstName}&lastName={lastName}

If We Were building thesis urls for Björk with firstName = Björk and lastName = Guðmundsdóttir They Would Be:

  • http://example.com/people/Björk-Guðmundsdóttir/SSN
  • http://example.com/query?firstName=Bj%c3%b6rk&lastName=Gu%c3%b0mundsd%c3%b3ttir


Java supports URI Template. Refer external links at the bottom

In Python 2.x, if you have the variable namethat you want to put in the string url, you can simply do this:

import urllib2
while "{name}" in url :
 if "?" in url and url . find ( "?" ) < url . find ( "{name}" ):
 url = url . replace ( "{name}" , urllib2 . quote ( name ), 1 )
 else :
 url = url . replace ( "{name}" , name , 1 )

Note: this will go into an infinite loop if name == "{name}"or other such corner boxes.

See also

  • European Legislation Identifier (URL template is used by ELI)