How can we learn openings?


I can tell you how I learned my openings.
I choose an opening that I feel suits my personal inclinations.
- I play the chosen opening in a rated game.
- I get crushed and lose horribly.
- I analyze the loss, with my own mind, NOT with an engine, and I figure out why I lost.
- Go back to 1. Loop until you UNDERSTAND the opening.
Seriously, nothing teaches you a proper lesson like having your butt handed to you.
... but nowadays, "The School of Hard Knocks" seems to be out of fashion.

Something else you can do that will help you learn your chosen opening:
Pick a Grandmaster (preferably, one from at least 50 years ago, not a modern Master) who plays the opening that interests you. Collect several of their games in that particular opening line, and play through the games from move one all the way to the end.
By reviewing the complete game (NOT just the opening moves) you will learn the opening line itself, plus the typical middle-game play that comes out of that line, plus some typical endgame play that is associated with that opening. This background info makes it much more likely that you will be able to find a sensible plan when you get taken "out of book" in your chosen opening line.