Set your oven to preheat at 350°F (175°C). In a mixing bowl, combine the softened butter and granulated sugar. Beat them together until the mixture is light and fluffy.
Gradually mix in the egg yolks, followed by the lemon zest and juice, and vanilla extract if using. Continue to blend until everything is well combined.
In a separate bowl, whisk together the all-purpose flour, baking powder, and salt. Slowly add the dry mixture to the wet mixture, stirring gently until just combined. Take care not to overmix.
Carefully fold in the raspberries to keep them intact, being gentle to avoid breaking them. Once combined, scoop the dough onto a floured surface and shape it into a log about 6 inches long.
Wrap the dough in plastic wrap and refrigerate for 30 minutes to firm it up. Afterwards, remove from the fridge and slice into 1/4-inch thick cookies, placing them on parchment-lined baking sheets.
Bake the cookies for 10 to 12 minutes or until the edges turn a light golden brown. Let them cool on the baking sheet for a few minutes before transferring to a wire rack.
For the optional lemon glaze, mix the powdered sugar with the lemon juice until smooth, then drizzle over the cooled cookies for a sweet finishing touch.