Deductions & credits

"For example, you can't contribute more than what you earn."

To be clear, "you" would be an individual when filing single or married filing separately; and otherwise for those married filing jointly "what you earn" would be as a couple, not as an individual.  Ergo, a non-working spouse who files married filing jointly may indeed contribute to his/her own individual HSA account and the couple still reap the tax benefit when filing their taxes jointly.