In general, when constructing logic puzzles, you don't start with the solution. Instead, you should solve the puzzle as you construct it: place clues, deduce what you can from those clues, place more clues, and so on. This method allows you to (1) force particular deductions to be made, and (2) ensure that there is a nice human-approachable path through the puzzle.
So, to construct a logic puzzle like this, I might start with a blank grid with all cells gray. Then I'll decide on a few cells, and see where that leads me.
Here I just placed two black cells, and a few white ones around them.
Then I deduced as much as I possibly could from just that information:
Alright, I like the logic at the end of the third row there. I might decide to build off of that logic -- I'll make another cell there white, and add a turn there as well.
One fun bit of logic you can use in loop puzzles is parity: if you look at any region of the grid, you have to enter and exit it the same number of times. So there must be an even number of entrances/exits to any region.
Additionally, if you checkerboard-color a region with red and blue, you have to alternate red and blue squares in that region. So if there are an even number of cells in that region, and you enter on a red cell, you have to leave from a blue cell.
So here, I've built a small 'room' in the bottom right.
You can't leave through the other upper exit; you have to leave through the left one. So that resolves that room entirely, and lets you continue part of the loop above it too.
I'll also put a black block in on the left. I'll use the same trick: forcing an entry into the lower-left region, so now there are two paths in/out of it.
So in particular, the cell in row 4, column 3, cannot be another entrance into the lower left region: then there would be three paths in and out of it. It must go upwards instead.
(I also decided that I wanted to make the bottom middle cell white, so I didn't "force" the exit there too early.)
And finally, I decided to put in one more black cell to make it resolve uniquely. I chose row 5, column 3, as that one didn't give much information by itself.
And now the puzzle's done! All that's left is to double-check that it has a unique solution (that can be found purely logically), and you're good to go!
This is a pretty simple example, but this is how all genres of logic puzzles are constructed -- at least, by hand. (Handmade logic puzzles are generally preferred by most logic puzzlers, because they can give more room for 'forcing' clever deductions to be made.)
If you're looking to do it by computer, you can do something similar to this if you program in the deductions. But the easiest way is to just generate a loop with a few cells skipped, and then try to solve the puzzle. There's not really much else you can do beyond that.