First of all. Fresh cables/housing. Then clamp the derailleur where you think it sits neat. Also check, manual for distance between derailleur cage and the chainring, if uts new you have a little plastic/tape with distance printed on it, wich you can use as a ruler, then attach the cable and stretch it out by pulling the derailleur out to the largest gear. So the chain cant jump of outwards and it isnt grinding the chain, also have the chain on small gear at the rear. Andjust the stop screw and then fasten the cable bolt. I use to do a small mark with a marker pen. Or use a small piece of tape, in case of tgat i have to re attach the cable, so that i have a reference when moving it up/down. Find the right tension on the cable. Test shifting. Adjust it sideways so it doesnt grind the chain, over the whole gear range. Test and trial. Use the shifter knob. Now it should work. In some cases it still wont. In some case ive had to bend the cage a tad, but not recomended. to make it work properly.and try to line the cable in big sweeps instead of small twisting turns. And adjust the stop screws. Make sure it doesn’t interfear with the shifter. Especially when shifting up tobthe large gear.