Optional components of a URL include the username, password, hostname, port number, pathname, search query, and hash. Even the hostname is optional if you have a file URL.