It's not an easy time to be a retailer.

Inflationary and recessionary headwinds have cooled off demand, especially for discretionary items, and the shift in consumer spending to services like travel and restaurants has also added challenges for the sector. In general, retail categories that thrived during the pandemic, like home goods and electronics, are now struggling.

Still, some retail stocks look like they're on sale after falling because of those headwinds, including two that reported earnings just this week: Target (TGT 0.18%) and Home Depot (HD 0.94%). Let's take a look at what each stock has to offer today.

A person looking at clothing in a retail store.

Image source: Getty Images.

1. Target: A uniquely diversified retailer

Target boomed during the pandemic as the company was perfectly positioned for the global health crisis with exposure to both consumer staples like groceries and consumer discretionary products like toys, apparel, and home goods.

Meanwhile, the company's omnichannel business model and store-based fulfillment strategy helped make it a winner, giving an option to customers who wanted to get their order without having to enter a store.

These days, Target's growth has slowed down considerably as those tailwinds have faded. Revenue grew just 0.5% in the quarter, and profits declined even as they topped expectations.

In other words, temporary macroeconomic challenges have pushed the stock price down as the stock is now down 40% from its peak in 2021, but Target's performance should get better in the second half as comparisons get easier.

However, the best reason to buy Target is its long-term growth potential. The company continues to open new stores, mostly small-format locations that complement its omnichannel strategy. It's remodeling existing stores, and it's building out its e-commerce network, adding new sortation centers to speed up delivery and make the process more efficient.

Target has also succeeded in differentiating itself from other retailers by investing in its owned brands, or in-house brands that aren't available anywhere else, which helps drive customer loyalty. The company now has at least 10 owned brands bringing in at least $1 billion in sales, and it's introducing more of them.

While 2023 results could be disappointing as the economy and retail demand normalize after the pandemic distortion, Target still looks poised for long-term growth, and the stock is well priced, considering its earnings potential.

2. Home Depot: Weathering the downturn

Like Target, Home Depot's sales also surged during the pandemic as demand for home improvement products spiked and home prices surged.

Now, the home improvement retailer is dealing with the slowdown in the housing market and posted a decline in revenue in its first quarter as comparable sales were down 4.5%, and overall revenue fell 4.2%.

Home Depot also lowered its guidance, calling for a comparable sales decline of 2% to 5% for the year and for earnings per share to fall 7% to 13%.

Shares sold off on the report, but long-term investors have a good buying opportunity here as Home Depot has long been the leader in home improvement retail, and the category still has a lot of growth ahead of it.

There's an estimated shortage of 4 million houses in the U.S., and mortgage rates may have peaked, or are near their peak, as the Federal Reserve has indicated that it's done raising interest rates. The National Association of Homebuilders has also reported a steady improvement in builder sentiment, a positive sign for recovery.

Over the last decade, Home Depot has demonstrated an ability to grow profits by investing in omnichannel capabilities and refraining from adding new stores. It's steadily expanded its operating margin, and it's returned capital to shareholders through both buybacks and dividends.

Home Depot should get back to that routine soon enough, and investors can take advantage of the sell-off as the home improvement retailer is valued at a price-to-earnings (P/E) ratio of 17.5, trading at a discount to the broad market.

For a stock with Home Depot's competitive advantage, that seems like a mistake. Investors should ignore the short-term headwinds here and take advantage of the discount in Home Depot stock.