Can you substitute butter for coconut oil?

In some baking recipes, you can substitute coconut oil for butter in a 1:1 ratio if the other ingredients in the recipe are at room temperature already (so the coconut oil would remain solid). However, the end result can have a slightly sweeter flavor and different texture due to the nature of coconut oil.

For other culinary uses like spreading on bread as is or substituting butter as a fat for cooking food in a pan, they have different smoke points that may affect results (coconut oil has a higher smoke point).