Many projects can get away without specifying their absolute URL anywhere outside of configuration. This is advantageous, since it allows the project to be deployed to any domain, and it allows the projects code to be shared with other developers. Unfortunately, there are a few cases where, for SEO purposes, the absolute URL is preferred. Fortunately, Vanilla Plus JS will convert relative URLs to absolute URLs in this context.
First, configure vanillaplusjs.json
to
include the true canonical URL of the project (note that configuration not
pertaining to canonical URLs is not included in this example):
{
"host": "example.com",
}
Then you can use the following tags with relative URLs and they will automatically be converted to absolute URLs. Furthermore, if neither a relative nor absolute URL is provided, it will match where the file is served from:
<link rel="canonical">
<meta property="og:url">