Using Static HTML instead of the `home_url()` WP function

href="https://wordpress.stackexchange.com/questions/350287/./contact-page"
  • if you’re on the homepage (/) this will become: /contact-page
  • if you’re on another page named foo (/foo/) this will become /foo/contact-page

This is due to ./ being a relative path. To avoid struggles like this, the method via home_url() is preferred because it creates absolute links/paths that will work from anywhere you call it.

Note:

You could use href="https://wordpress.stackexchange.com/contact-page" which is relative as well, but only to the domain and not the current page. However I can’t tell you why WP rather uses and stores absolute URLs.