To get URLs such as example.com/sample-post/, go to SettingsPermalinks and select Post name. The default Plain option gives URLs such as example.com/?p=123. The screen is the same in classic and block themes.
- Go to SettingsPermalinks.
- Under Common Settings, select Post name.
- Click Save Changes.

The other options are Day and name, Month and name, Numeric and Custom Structure.
The Optional section on the same screen sets the Category base and Tag base in archive URLs. Leave them blank to use the defaults.
Changing the structure on a live site changes the URL of every post. Set up redirects first if the site already has visitors or search traffic.
If pages show a 404 error after the change, your server must allow URL rewriting. Apache uses mod_rewrite. Nginx needs rewrite rules in its configuration. Ask your host to check.
See Customize Permalinks for more.