Truncate hashes without breaking searchability

Web pages which need to render git hashes (or any hashes really), tend to simply truncate the hash. They might show the first seven characters, 6831795, instead of the full hash; saving space on the page. Such truncation breaks the ability to search for the hash if you are copy-pasting the full hash in your browser's search box. Try searching for 6831795d653e1f0cf0ccd02a7a45850098db692a on this page.

A better approach is to leave the entire data in the page and use css to only display a prefix. For example, 6831795d653e1f0cf0ccd02a7a45850098db692a, is truncated using css and can still be searched for using the full hash.


Try searching for the trailing characters (say "8db692a") and you'll hit an edge case where the browser's search result will cycle through hidden text. IMHO the advantage of using css to truncate hashes outweighs this caveat.