Avoiding detours (bike profile)

Is there way to avoid short detours? I could probably bump up priority for primary in bike profile but is there some other way? Like to do not do detour when we go back to the original road anyway.

This is tricky.

The problem is that we tell the engine to avoid primary roads and accept a certain detour for this. The resulting route also does not look wrong and is only slightly longer. Why would you still prefer the primary road for a normal bike? Is the unpaved surface the problem?

Using the racingbike profile you can see that the priority is different and it accepts the primary road.

Unpaved surface is one of the problem but in this example you will have to go extra 20m uphill. Plus this short detour doesn’t feel right, I mean, you still have to go back to the main road anyway.

But I get it could be tricky to avoid “short detours” and do not change primary road priority.

Unpaved surface is one of the problem but in this example you will have to go extra 20m uphill.

But then this is the problem and not the detour. Did you try with more precise elevation data or a different smoothing algo etc? This might already improve things.

you still have to go back to the main road anyway

One possibility is to increase turn costs which reduces turns in general, but from my experiments that should be done with great care as otherwise the bike routes will often end up on bigger roads as for them there are often less turns involved. And once you cannot increase the turn costs that much this won’t improve the resulting routes a lot. Another idea would be to avoid road_class changes (i.e. like turn costs but only if the road_class changes)