Links, URLs, and embeds


It surprises me how many writers don’t understand how links work. Here’s a brief guide on some technical (but not too technical) points.

The structure of a URL

Understanding HTML isn’t essential to writing an article. Usually you work in an editor that takes care of those details. But you can’t get around understanding links. A link uses a uniform resource locator or URL. Here’s what it looks like:

https://www.example.com/path/file

The first part is the protocol. For your purposes, it will always be “http” or “https”. It can be upper or lower case without making any difference. HTTP is the original protocol for Web pages; HTTPS is the secure version. You can often replace one with the other and have your browser get to the same place, but it’s not guaranteed. There are still many sites that support only HTTP.

The protocol is always followed by the string “://”. No one seems to know why the Internet’s creators went for a three-character string when one character would have done fine. Many browsers fill in “http://” or “https://” if you omit it in the address bar, but you can’t leave it out in a link. If you just give “www.example.com/path/file”, it won’t work, and people clicking the link will get a confusing error message.

Some editors might fill the protocol in for you. But HTTP and HTTPS links aren’t the same, so the best practice is to put in the exact URL. Then you know it’s what you intended.

HTTPS URLs are greatly preferred for serious work these days. Your customer may require them. If you get an HTTP URL, you can sometimes promote it to an HTTPS URL just by changing the protocol. It depends on the site. There’s no guarantee it will work, so be sure to test any URL you alter. (You test all your links before submitting anyway, don’t you?)

You may sometimes see a URL called a URI. They’re the same thing, except that a URI is more abstract and doesn’t always point to a page. For your purposes, they’re the same thing.

The next part is the domain. It could be an IP address, but that’s rare. In this case, the domain is “www.example.com”. I use example.com because it’s a reserved domain name that will never have any real content.

The domains “www.example.com” and “example.com” aren’t the same. The first one is a subdomain of example.com. By convention, “www” is a subdomain used for a domain’s website, but it doesn’t have to work that way. On many sites, it makes no difference whether you use “www” or not, but that’s because they set it up that way. To be safe, keep the link you’re given exactly as it is, as long as it works.

The rest of the URL is the path. It directs the browser to a particular location on the website. If there’s a slash at the end of the path, you can usually omit it or not without changing the location. The safest practice is to leave it as you got it.

A few (minor) complications

Sometimes you’ll find variations on this scheme. A URL can have parameters after the path. Here’s an example:

https://www.example.com/path/file?id=2422&view=default

A question mark introduces the parameters. If there’s more than one, they’re separated by ampersands. They may affect the formatting, provide tracking information, or play an essential role in finding the right information. Sometimes you can remove parameters to shorten the URL and remove someone else’s tracking, but you have to know what you’re doing. That’s too advanced a topic to cover here.

Another variant is an anchor. It looks like this:

https://www.example.com/path/file#part2

The text after the pound sign is the anchor. The normal use is to make the browser scroll to a particular point in the page. Sometimes, though, the anchor is a parameter for JavaScript, and the page won’t display correctly if you take it out.

It’s a common mistake for people who supply URLs to give an anchor when they really want people to see the top of the page. The do it because they copied someone else’s link to the middle of the page. If a link takes your browser to the middle and it seems like a mistake, try removing the anchor. Make sure it works in a reasonable way before submitting the article with the altered link.

One type of URL doesn’t need a protocol. That’s a relative URL. It’s used only to get from one page in a site to another. For instance, if you’re at the homepage of example.com and it has a link of “about.html”, clicking on it will take you to example.com/about.html. As a writer, you don’t normally know where the piece you’re writing will go in the website’s directory structure, so you’ll probably never have a reason to use a relative URL.

Image URLs

URLs for embedded images work the same way, though the HTML syntax is different. Be sure to use the URL for the image, not for the page containing it. The path for an image URL will usually end in .jpeg, .png, .gif, or something like that, never in .html. Formatting is normally up to the customer, though you may be asked to provide an alt text and caption. The alt text is a very short description of the image for users who are visually impaired or use text-only browsers.

I hope this article has helped you to understand how to use links in your writing. Feel free to share the link to this article, of course. Just for practice.