Composting weeds can make some gardeners nervous, thinking that they are going to end up spreading the weed all around their garden whenever they spread compost. Troublesome weeds such as couch grass, nettles, buttercups and ground elder, have large root systems. Their root systems are what makes them such prolific growers and so hard to eradicate from your garden. These roots absorb huge amounts of valuable nutrients from the soil.
What does that mean?
Don’t throw them away! Your garden can benefit from all of those extra nutrients. Leaves aren’t the only thing you should be composting from your yard!
By following these few simple tips you can compost weeds without the risk of spreading them throughout your garden.
Remember: We will never eradicate weeds, they blow about, birds drop them and they can sleep in the soil for years then soil disturbance will set them off.

source
If your compost pile gets plenty of heat and is steaming to the touch, then weeds can compost in as little as 6 to 8 months. To get your compost piles hot enough requires a perfect mix of browns and greens, regular working and (ideally) a sunny location. The heat from your compost should damage and destroy roots and seeds so that your weeds will not propagate from the compost.
However, for most of us, it isn’t as easy as that. Unfortunately, most home compost bins do not get hot enough to destroy all seeds and roots. Smaller and slower acting compost piles may take up to two years to kill weeds. This does not fit in with most people’s annual rotations of their compost piles, so this method is out for many gardeners.

If your compost pile doesn’t heat up enough — don’t worry, most domestic sized composters don’t — then you need to use a different approach. You need to make….weed soup!
During hot summers, you can take advantage of the sun’s heat to desiccate your weeds. Lay the roots of your perennial weeds on concrete or corrugated iron (keep them off the soil). Allow the summer sun to dry them out for 2 to 3 weeks. The roots should then be baked hard and are safe to add to your compost pile.

If you have a large quantity of weeds to get rid of then you can simply bag them in compostable bags (ideally paper yard waste bags). Find a convenient place to ‘hide’ these bags; such as behind your garden shed. Cover with black plastic, or carpet (something to exclude the light). Leave for 2 to 3 years.
This should be long enough to kill even the toughest weeds. You can then use the resulting compost on your garden.
Bokashi composting is a popular method for composting food waste. Bokashi composting can also be used effectively to compost weeds. The bokashi composting process uses microbes to ferment organic material. This fermentation process creates an acidic environment which will kill seeds and roots of your weeds.

To compost weeds in a bokashi system:
Learn more about how to compost with the bokashi method. Note that this link refers mainly to composting food waste, but the same methods can be applied to “bokashi’ing” weeds in your garden.
Disclaimer: Check your local regulations on disposing of certain invasive species (such as Japanese knotweed). Japanese Knotweed is a notifiable contaminated substance if removed from your garden. Both the weed and the surrounding earth should be removed.