f4 weakens the kingside. Black can then play Ng4, followed by Rf1 Nxh2 Rh1. h3 is better to prepare kingside castling.
3 Key Takeaways
The recurring theme in your error appears to be weakening your King's position with pawn moves too early in the game.
Here's some actionable advice for your next game:
Prioritize King Safety: Before advancing pawns around your King, consider the potential vulnerabilities it creates. Ask yourself: Does this pawn move create a weakness that my opponent can exploit?
Develop Pieces First: Focus on developing your knights and bishops to good squares before* making pawn moves. A well-developed army can better defend against attacks on the kingside.
Consider Prophylactic Moves: Instead of weakening pawn moves, look for moves that actively prevent your opponent's plans. h3, as suggested, is a great example of a move that anticipates and neutralizes a future threat. Keep practicing and you'll improve!
Annotated PGN
Copy this PGN to paste into Lichess, ChessBase, or any analysis tool.