There are only two ways to get digital audio between your TV and soundbar, or your TV and receiver, or really between any piece of gear that transmits audio in a home A/V system: HDMI and optical.
If you have a fancy home theater system with a soundbar and surround sound speakers, then how you connect it to your TV is an important consideration. There are legacy options you may be more familiar ...