Getting links right


Links are important in blog posts and Web pages. They give support to statements and lead the reader to further information. They make the page more valuable and trustworthy in the reader’s eyes. Broken links, on the other hand, make a page look dubious and outdated. A writer needs to pay special attention to get the links right.

Anatomy of a URL

Links are URLs (Uniform Resource Locators). They consist of a protocol, normally HTTP or HTTPS, plus a domain and a path. They may also contain parameters. For the article you’re reading, the protocol is HTTPS, the domain is garymcgath.com, and the path may vary depending on how you’re viewing the piece. The protocol is a mandatory part of the URL. garymcgath.com is not a URL, and putting it into a link will work only if the server is kind enough to fix it for you. https://garymcgath.com is a URL with an empty path. https://garymcgath.com/wp/blogging is a URL that points at my blog.

The “www” which you see in many links is a part of the domain name. Many sites are set up so that you’ll get to the same place whether you go to www.foomumble.com or foomumble.com. However, that’s just a convention, and not everyone uses it. Don’t reflexively add or remove a “www” from a link.

Secure protocols

The HTTPS protocol indicates that the page is secure. It’s very difficult to hijack or alter the content in transit, but it doesn’t protect you against an infected or malicious website. Many sites that support HTTPS will automatically redirect from an equivalent HTTP URL. This isn’t guaranteed, though, so you should avoid accidentally changing the protocol. It’s more secure to use the HTTPS URL directly.

Tracking parameters

Many URLs include parameters. They’re introduced by a question mark, and multiple parameters are separated by ampersands. Here’s an example that does nothing:

https://garymcgath.com?param1=something&param2=something_else

My website knows nothing about those parameter names, so they have no effect. It’s just an illustration.

Sometimes parameters identify the page you’re pointing at, and removing them will break the link. Sometimes, though, they contain tracking information. They’re giving credit to whatever site added the parameter rather than to you. Removing them makes the URL shorter. These parameters most commonly start with “utm_”. If you see parameters such as “utm_content”, “utm_campaign”, and “utm_source”, you can safely remove them. It’s not a big deal, but removing them makes your links cleaner and avoids giving a free ride to a stranger.

Anchors

A URL may contain an anchor. It’s introduced with the # character and comes before any parameters. It can direct the browser to scroll to a location within the page. It can also direct JavaScript to show particular content. You should leave anchors alone unless you know of a reason to remove or change them. Here’s an example which does nothing, since the anchor isn’t defined:

https://garymcgath.com#somewhereinthemiddle

Relative links

Within a website, you can use relative links. They’re incomplete URLs, without a protocol or domain. They’re shorter than full URLs and remain valid if you move the whole site to a different location. If you move the referring page, though, you can break the link. Use them with care or always use full URLs.

Hidden information

Many browsers dumb down what you see in the address bar. They omit the protocol and sometimes even the path. This makes it harder to get the URL right or see whether you’ve got a secure connection. Browser makers can display whatever they like, but that doesn’t mean you can paste what they show and get a valid link. Make sure that any link you post includes the protocol, full domain name, and path. Don’t change or remove anchors and parameters unless you know what you’re doing. Then you’ll have working links, and your readers will believe you know what you’re doing.