Gh is a digraph found in many languages.
In English ⟨gh⟩ historically represented [x] (the voiceless velar fricative, as in the Scottish Gaelic word loch), and still does in lough and certain other Hiberno-English words, especially proper nouns. In the dominant dialects of modern English, ⟨gh⟩ is almost always either silent or pronounced /f/ (see Ough). It is thought that before disappearing, the sound became partially or completely voiced to [ɣx] or [ɣ], which would explain the new spelling — Old English used a simple ⟨h⟩ — and the diphthongization of any preceding vowel.
Alexander John Ellis reported it being pronounced as [x] on the Yorkshire-Lancashire border and in close to the Scottish border in the late nineteenth century.
It is also occasionally pronounced [ə], such as in Edinburgh.
When gh occurs at the beginning of a word in English, it is pronounced /ɡ/ as in "ghost", "ghastly", "ghoul", "ghetto", "ghee" etc. In this context, it does not derive from a former /x/.
American Literary Braille has a dedicated cell pattern for the digraph ⟨gh⟩ (dots 126, ⠣).
In Middle Dutch, ⟨gh⟩ was often used to represent /ɣ/ (the voiced velar fricative) before ⟨e⟩, ⟨i⟩, and ⟨y⟩.
The spelling of English word ghost with a ⟨gh⟩ (from Middle English gost) was likely influenced by the Middle Dutch spelling gheest (Modern Dutch geest).
In Italian and Romanian, ⟨gh⟩ represents /ɡ/ (the voiced velar plosive) before ⟨e⟩ and ⟨i⟩. In Esperanto orthography, ⟨gh⟩ (or ⟨gx⟩) can be used when the ⟨ĝ⟩ is missing, which represents /dʒ/. In Galician, it is often used to represent the pronunciation of gheada.
In Irish, ⟨gh⟩ represents /ɣ/ (the voiced velar fricative) and /j/ (the voiced palatal approximant). Word-initially it represents the lenition of ⟨g⟩, for example mo ghiall [mˠə ˈjiəl̪ˠ] 'my jaw' (compare giall [ˈɟiəl̪ˠ] 'jaw').
In Juǀʼhoan, it's used for the prevoiced aspirated velar plosive /ɡ͡kʰ/.
In the Malay and Indonesian alphabet, ⟨gh⟩ is used to represent the voiced velar fricative (/ɣ/) in Arabic origin words.
The Maltese language has a related digraph, ⟨għ⟩. It is considered a single letter, called għajn (the same word for eye and spring, named for the corresponding Arabic letter ʿayn). It is usually silent, but it is necessary to be included because it changes the pronunciation of neighbouring letters, usually lengthening the succeeding vowels. At the end of a word, when not substituted by an apostrophe, it is pronounced [ħ]. Its function is thus not unlike modern English gh, except that the English version comes after vowels rather than before like Maltese għ (għajn would come out something like ighn if spelled as in English).
In the Roman Swahili alphabet, ⟨gh⟩ is used to represent the voiced velar fricative (/ɣ/) in Arabic origin words.
In Canadian Tlingit ⟨gh⟩ represents /q/, which in Alaska is written ⟨ǥ⟩.
In Daighi tongiong pingim, ⟨gh⟩ represents /ɡ/ (the voiced velar stop) before ⟨a⟩, ⟨e⟩, ⟨i⟩, ⟨o⟩, and ⟨u⟩.
In Uyghur Latin script, gh represents [ʁ].
In Vietnamese alphabet, ⟨gh⟩ represents /ɣ/ before ⟨e⟩, ⟨ê⟩, ⟨i⟩.
In the romanization of various languages, ⟨gh⟩ usually represents the voiced velar fricative (/ɣ/). Like ⟨kh⟩ /x/, ⟨gh⟩ may also be pharyngealized, as in several Caucasian and Native American languages. In transcriptions of Indo-Aryan languages such as Sanskrit and Hindi, as well as their ancestor, Proto-Indo-European, ⟨gh⟩ represents a voiced velar aspirated plosive /ɡʱ/ (often referred to as a breathy or murmured voiced velar plosive).
In the romanization of Ukrainian language ⟨gh⟩ is used seldom to avoid occurrence of another digraph, usually ⟨zh⟩ which is used for another type of phoneme. Such as the word "flock" in Ukrainian would be Romanized as zghraya (Ukrainian: зграя) rather than zhraya, which could be misconstrued to intend *жрая.