Article III, Section 2 of the California Constitution provides that "Sacramento is the capital of California". The building in which the legislators meet, however, is denominated the "capitol" building. Thus, the state capitol can be found in the state capital. But why the variant spelling?
Both words are derived from the Latin word for head - caput. "Capital" is formed by joining caput to the suffix -alis meaning "characteristic of". A capital is figuratively the head of the particular jurisdiction in which it is located.
The etymon of "capitol" is also caput, but the term was applied in its literal, not figurative, sense. Here, is the story according Titus Livius (aka Livy) who lived in the first centuries B.C.E and C.E.:
[S]ecutum aliud magnitudinem imperii portendens prodigium est: caput humanum integra facie aperientibus fundamenta templi dicitur apparuisse. quae visa species haud per ambages arcem eam imperii caputque rerum fore portendebat . . . .
Another prodigy portending the greatness of the empire followed: a human head with a whole face is said to have appeared to those excavating the foundation of the temple [of Jupiter Optimus Maximus]. The appearance was by no means ambiguously foretelling that this will be citadel of the empire and the head of the world . . . .
T. Livy, Ab Urbe Condita (From the Founding of the City), Book 1, ch. 55, 5-6 (my translation). The hill on which the temple was built was accordingly called the Capitoline Hill (Collis Capitolinus).
The Capitoline Hill in Rome