Initialize git repo to organization rather than user in PkgTemplates.jl

I would like to create a template from PkgTemplates to simplify the package generation procedure for some colleagues within my organization.
We have set up a group on a self-hosted gitlab instance and I would like all of the packages created with this template to automatically set up the repo url using the name of the group, rather than the name of the specific user creating the package from the template.

I had a look at the code of the Git plugin that initializes the repository and it seems it always initialize this using the specific user given to the template (specifically at lines 71-74 below):

I could have the users change the repo location to point to the group rather than their user after creating the package but I’d like to avoid requiring manual intervention to reduce the chance of issues.

Is there already a way to achieve this via PkgTemplates or am I to create a custom Plugin or custom wrapper around the Template to perform this modification?

Just for your information, siince you are talking about a Gitlab self-hosted instance, have a look at Julia and Gitlab self-hosted : a state-of-the-art?.

Thanks @BambOoxX, I have actually used your other thread as reference already for setting up quite some things on our instance, but unfortunately I do not see anything useful for the topic here (which I believe is relevant also outside of gitlab, self-hosted or not).
I notice that in your thread at some point you mentioned that PkgTemplates.jl does not seem suited for handling tasks at a level higher that the specific package repository (so Registry or Group), did you ever get a reply or managed to make PkgTemplates.jl work, or you simply avoided using that?

For whomever might be interested in this functionality, I managed to make it work by creating a custom plugin that I add to the default template in my setup package.

The code is basically this:

module BasicSetup

using PkgTemplates
import PkgTemplates: @with_kw_noshow, priority, prehook, @plugin, Plugin, validate
import LibGit2: LibGit2, GitRepo, ref_list, lookup_remote, set_remote_url, add_push!

export MyTemplate, GitGroup

# We create a simple plugin that modifies the git config to assign a group

@plugin struct GitGroup <: Plugin
    name::AbstractString = "<default group name>"
priority(::GitGroup, ::typeof(prehook)) = 100 # We make it go after Git
function validate(::GitGroup, t::Template)
    # Here we just make sure that Git is a plugin of t, 
    git_idx = findfirst(x -> x isa Git, t.plugins)
    if git_idx isa Nothing
        throw(ArgumentError("The GitGroup plugin can only be used if the Git plugin is also loaded"))
function prehook(g::GitGroup, t::Template, pkg_dir::AbstractString)
    repo = LibGit2.GitRepo(pkg_dir)
    remote = LibGit2.lookup_remote(repo, "origin")
    # We change the remote url to have the group name rather than the user name
    new_url = replace(LibGit2.url(remote), "$(t.user)" => "$(")
    set_remote_url(repo, "origin", new_url)
    # We add the push upstream
    ref = first(ref_list(repo))
    add_push!(repo, remote, ref)

function MyTemplate(;
        host = "<your host>",
        julia = v"1.9.0",
        plugins = [],
    default_plugins = [
		ProjectFile(;version = v"0.1.0"), 
	plugins = [
        default_plugins..., # The first instance of the plugin is retained if multiple are present


This way the user just has to load BasicSetup and create an instance of MyTemplate with their user and email and the custom Plugin takes care of changing the git repo url to point to the group rather than the user, and also sets up the default upstream so that the user can simply create the new project on the git server (in our case, self-hosted gitlab) without requiring to create a project from the Web GUI first.

Seems like I over-complicated stuff.

After looking at the PkgTemplates.jl code better I think it is sufficient to just put the group/organization name as the user kwarg in the Template, and just make sure that the name and email in the Git plugin are the ones needed for authentication (in my case to the self-hosted gitlab).

Did some basic tests and it seems to work fine without requiring to define new plugins