Permutation codes have received a great attention due to various applications. For different applications, one needs permutation codes under different metrics. The generalized Cayley metric was introduced by Chee and Vu (in: 2014 IEEE international symposium on information theory, Honolulu, June 29-July 4, 2014, pp 2959-2963, 2014) and this metric includes several other metrics as special cases. However, the generalized Cayley metric is not easily computable in general. Therefore the block permutation metric was introduced by Yang et al. (IEEE Trans Inf Theory 65(8):4746-4763, 2019) as the generalized Cayley metric and the block permutation metric have the same magnitude. In this paper, by introducing a novel metric closely related to the block permutation metric, we build a bridge between some advanced algebraic methods and codes in the block permutation metric. More specifically, based on some techniques from algebraic function fields originated in Xing (IEEE Trans Inf Theory 48(11):2995-2997, 2002), we give an algebraic-geometric construction of codes in the novel metric with reasonably good parameters. By observing a trivial relation between the novel metric and block permutation metric, we then produce non-systematic codes in block permutation metric that improve all known results given in Xu et al. (Des Codes Cryptogr 87(11):2625-2637, 2019) and Yang et al. (2019). More importantly, based on our non-systematic codes, we provide an explicit and systematic construction of codes in the block permutation metric which improves the systematic result shown in Yang et al. (2019). In the end, we demonstrate that our codes in the novel metric itself have reasonably good parameters by showing that our construction beats the corresponding Gilbert-Varshamov bound.