From Liquipedia StarCraft Brood War Wiki
150 0 38
B → G
The Gateway is a Protoss building that is used for building infantry units. Protoss players make heavy use of every unit produced at the Gateway, making it the most important production building in every Protoss match-up. Players typically make many Gateways to increase their unit production capacity. More Gateways can be made for each expansion taken due to the improved economy. Gateways must be built within the Pylon Psionic Matrix.
Analogous to the Terran Barracks, the Gateway does not research any upgrades, but produces a variety of units.
The Protoss player typically decides early on which part of the base is dedicated to Gateways, as the structure is relatively bulky and requires an efficient building formation to fit the maximum number of Gateways. It is common to build Gateways close together in a linear formation or surrounding one or two Pylons. This closely grouped formation enables the Protoss player to quickly select and produce new units. This also obviates the need for the Protoss player to hot key each Gateway, as several of them can be clicked on in quick succession.
In the PvZ match-up, in build orders such as the Fast Expand, the position of the Gateway (and Forge/Pylon) Sim-City is vital in preventing a Zergling Run-by by the Zerg opponent.
In the PvT match-up, the Gateway is also sometimes used to build a wall at the natural base to block off Terran Vultures.
The Protoss player sometimes elects to make Proxy Gateways to speed up a rush attack or execute a surprise attack (e.g. Dark Templars). Such Gateways are placed near or inside the opponent's base. In team play, Gateways can be built inside an ally's base; for example, to build High Templars with Psi Storm to help the ally in either attacking or defending.