How to render the URL of the current sub-site in a Masterpage

I came across a seemingly simple to find token issue but could not find the answer to it so easily.  I wanted to render the URL path into the HTML of my Masterpage.  It took me quite a while to find the answer so I thought I would add it to my blog to make it a little easier for others to find.  It is actually quite simple; you utilize the SPUrl token from SharePoint.  Here it is used in a hyperlink:

<a href="<% $SPUrl:~site/_layouts/Authenticate.aspx %>" runat="server">Sign In</a>

This is a simple login link that if clicked on, an authenticated user will be logged into the sub-site of whatever page they were just on.

You can use this token in may other ways, of course!

You can add any further path you need after ~site/  The critical part is to remember to use the runat=”server” in the tag or it won’t work.