You shouldn't. D&D 5e doesn't grant XP for dealing with traps, any more than it grants XP for "defeating" other environmental hazards like not falling into a lava pit or off a cliff, or not dying of thirst while crossing a desert. Disarming or cleverly circumventing a trap is its own reward — you get to access whatever it was guarding — just like not being swept away by the river at the bottom of a cliff or reaching your destination across the desert is its own reward.
Making traps grant XP can easily result in them becoming dull "roll to farm some XP" non-encounters. It also encourages making them non-optional, when the most interesting way of dealing with a trap is often to creatively circumvent it rather than simply disarm it with a skill check.
But other editions give XP for traps?
Those are different games with different designs. Besides, only two editions out of (a conservative count of) seven give encounter XP for traps: 3rd and 4th. (Second edition does optionally give rogues XP for using their special abilities, which happens to include disabling traps, but that's not an example of making traps give encounter XP any more than the rest of the optional per-class XP rewards — like researching a spell — are.)
With those two most-recent editions very obvious to the 5th edition designers, the fact that it lacks XP rewards can only be deliberate, not an oversight. And, with the 5e designers explicitly saying that they draw inspiration for the game from older editions than 3e, the role of traps in 5e matching the role of traps in AD&D and earlier is no coincidence.
The role of traps in those older editions is as an element of environment to be explored and dealt with using thought and available resources. Fifth edition's design including traps with that role makes them a core component of what 5e calls its Exploration pillar; they are obstacles to deal with creatively and with player agency to choose, just like any other obstacle the players discover (including monsters, which players are not required to always deal with using violence!).
You can give XP for non-combat challenges at your discretion
The very loose guidelines for giving experience for non-combat challenges (DMG p. 261) can be used to have traps give XP in your campaign, but I won't recommend doing it per-trap as you may be used to different D&D games doing it. Notice that the examples given in the guidelines are large achievements — a tense political negotiation, establishing a trade treaty, navigating the pitfalls of an entire location — not little things like dealing with a spring-loaded spear trap.
Instead, if you opt to use this discretionary rule, save "trap XP" for dealing with some fiendishly-complicated device that involves players exploring and experimenting to find the solution to it, not just a skill check. Navigating the Clockwork of Time to locate its malfunction — while avoiding getting crushed by enormous gears, smashed by weights, and impaled by broken springs — is the sort of thing that involves traps, but where it's the whole enterprise is what's worth XP, not any one trap. (If that kind of "trap dungeon" doesn't sound like fun, obviously don't use them.)
Finally: it's your game
If you really want to, give XP for traps. No 5e DMing police will stop you. Just beware that it has been left out of this edition for reasons which might not be obvious now, and might only become obvious by seeing how not giving XP for them changes how you use them in your dungeons and how your players' behaviour around traps changes.
Not discovering these things is missing some of the value of this edition. But, some of the other value of this edition is that it is very bendable to suit your and your group's preferences. Pick between those with knowledge of what you're doing, and you can't actually go wrong.