Gold has quietly hit an all-time high -- overshadowed by S&P 500 and Nasdaq Composite records.

You may be considering gold if you feel the market rally is about to cool off or you don't want to put new capital to work in stocks with stretched valuations.

Here's why gold is rallying, how to invest in it, and whether it's the right choice for you.

A golden bull on top of sheets of U.S. $100 bills.

Image source: Getty Images.

Why gold (finally) broke through to a new all-time high

As with any asset, there are many logical and random reasons why gold can go up or down. But there are some factors worth pointing out that could lead to a sustained rally.

The first is overall higher asset values. The S&P 500 is around an all-time high. The cryptocurrency market has rebounded. Real estate remains strong. Prices are higher across asset classes. Part of gold's run-up is due to a rising tide lifting all ships.

Another catalyst is momentum. Gold hit a record high on March 8 and is up close to another 3% since that high. It has been a long time coming.

Gold first broke above $1,800 an ounce in 2011. It took until summer 2020 for it to pass the $2,000 mark before pulling back. Gold currently sits around $2,255. It's a solid year-to-date gain, but a terrible performance relative to other asset prices since that previous high back in 2011.

Another reason gold could be going higher is geopolitical tensions and currency/economic weakness in China. China has been consistently buying gold for stability. Gold can do well when uncertainty is high. And although the global economy is doing quite well, there are cracks amid big-time players like China that can fuel gold demand.

Ways to invest in gold

Buying physical gold bullion can lead to high purchase, storage, and insurance fees and can be a security risk. A better alternative is to invest in a gold exchange-traded fund (ETF), like SPDR Gold Shares (GLD -0.01%) or the iShares Gold Trust (IAU -0.02%).

SPDR Gold Shares has $54.2 billion in net assets and a 0.40% expense ratio compared to $25.6 billion in net assets and a 0.25% expense ratio in the iShares Gold Trust.

Both financial products use a custodian that holds physical gold on their behalf. The two ETFs trade almost identically and have achieved respectable results over the last five years compared to the S&P 500.

GLD Chart

GLD data by YCharts

A riskier option is to invest in gold miners. Each gold miner has different geographic exposure, leverage, and operational efficiency -- so it's important to do your own research on gold miners before investing in a specific one.

Why gold may not be right for you

Earnings drive the long-term performance of the U.S. stock market. The prospect of earnings growth fuels valuation expansions. Innovation and sustained leadership across sectors have been the main reasons why the stock market continues to be an excellent vehicle for building wealth.

Like other commodities, the value of a precious metal like gold is based on supply and demand. But gold is different because most of it is purchased and held rather than used, like oil, gas, soy, wheat, and lumber.

Some gold miners pay dividends, but physical gold and gold ETFs do not. Gold doesn't have an income statement or a balance sheet. Its growth is based on external factors.

Gold isn't the worst idea if you're looking to allocate a portion of your portfolio to a safe asset with recession resistance. It could even be better than cash over time. But it isn't ideally suited for investors with a long-term time horizon or a high risk tolerance.