Astronomers use various methods to measure the distance to celestial objects, such as parallax, standard candles (like Cepheid variables and supernovae), and redshift measurements. These techniques help determine the distance, which is essential for calculating the absolute magnitude.