You can decide to create your categories before or during categorizing your transactions. If you want to create your categories beforehand, see the article: Adding new categories. Otherwise you can just add new transactions while categorizing your existing transactions.
Automatically categorize your transactions with Filters and Category Rules
The best way to categorize your existing transactions, as well automating categorization of your future transactions is by creating Filters and Category Rules.
Filters allow you to use the powerful search criteria to categorize or edit your transactions. See the article: Using Filters to automatically categorize and edit transactions
Category Rules are a type of Filter that just categorizes transactions. See the article: Using Category Rules to automatically categorize transactions
Manually categorize your transactions
You can categorize an individual transaction or multiple transactions at a time.
To categorize a single transaction, see the article: Edit a transaction
To categorize many transactions in bulk, see the article: Categorize your transactions