Op amp: single supply amplification
In order to simplify things a bit, you need to consider A.C. and D.C. gain separately for this A.C. coupled circuit.
At D.C. capacitor C2 is effectively 'open' i.e. high impedance. The value of R1 is no longer important and the feedback is 100%, therefore there is no gain. This means that the output 'sits' at Vref (+2.5V in this example) in the 'quiescent' state. This amplifier configuration is termed a voltage follower and the D.C. that's added to the A.C. signal (Vref) is usually referred to as an 'offset' which does indeed allow A.C. signals to be amplified.
For A.C. signals the gain is indeed 1+(R2/R1) and the output requires A.C. coupling in the same way as the input. As there's no gain at D.C. there's no requirement to consider the offset as part of the input signal as it 'drops out of' the in band A.C. gain equation.