Random graphs with power-law degrees can model scale-free networks as sparse topologies with strong degree heterogeneity. Mathematical analysis of such random graphs proved successful in explaining scale-free network properties such as resilience, navigability and small distances. We introduce a variational principle to explain how vertices tend to cluster in triangles as a function of their degrees. We apply the variational principle to the hyperbolic model that quickly gains popularity as a model for scale-free networks with latent geometries and clustering. We show that clustering in the hyperbolic model is non-vanishing and self-averaging, so that a single random graph sample is a good representation in the large-network limit. We also ...