Build up in tiny steps
Start with a few seconds behind a gate while you are still in the house, then a minute, then a short trip outside. Come back before they get upset, so being alone stays boring.
As a guide, most adult dogs should not be alone more than four hours
Young puppies need much shorter gaps, and toilet breaks every couple of hours. For long workdays, a dog walker, a friend or doggy day care can break up the time.
Leave them something to do
A stuffed food toy, a lick mat or a safe chew gives them something to look forward to as you leave. Automatic feeders are fine for timing a meal, but they do not replace company.
Watch for signs of distress
Howling, scratching at doors, drooling or toileting only when you are out can mean your dog finds being alone very hard. A pet camera helps you see what happens. This is worth getting help with early from your vet and a reward-based professional.