diff --git a/lib/workers/repository/updates/branch-name.spec.ts b/lib/workers/repository/updates/branch-name.spec.ts
index c78652419cc6c2660fd59f937ffd6ab1e4f20e4d..62da7332c99dd1f0ca42fddea759ed9dbbd36dc2 100644
--- a/lib/workers/repository/updates/branch-name.spec.ts
+++ b/lib/workers/repository/updates/branch-name.spec.ts
@@ -31,14 +31,15 @@ describe('workers/repository/updates/branch-name', () => {
     it('uses groupSlug if defined', () => {
       const upgrade: RenovateConfig = {
         groupName: 'some group name',
-        groupSlug: 'some group slug',
+        groupSlug: 'some group {{parentDir}}',
+        parentDir: 'abc',
         group: {
           branchName: '{{groupSlug}}-{{branchTopic}}',
           branchTopic: 'grouptopic',
         },
       };
       generateBranchName(upgrade);
-      expect(upgrade.branchName).toBe('some-group-slug-grouptopic');
+      expect(upgrade.branchName).toBe('some-group-abc-grouptopic');
     });
 
     it('separates major with groups', () => {
diff --git a/lib/workers/repository/updates/branch-name.ts b/lib/workers/repository/updates/branch-name.ts
index 9036a161c07fe1bcd73f427ed85fb672797e94f9..7200b12ecfee490f97e9c817e21a56aeb33a1ef3 100644
--- a/lib/workers/repository/updates/branch-name.ts
+++ b/lib/workers/repository/updates/branch-name.ts
@@ -54,7 +54,12 @@ export function generateBranchName(update: RenovateConfig): void {
     logger.trace(
       `Dependency ${update.depName!} is part of group ${update.groupName}`,
     );
-    update.groupSlug = slugify(update.groupSlug ?? update.groupName, {
+    if (update.groupSlug) {
+      update.groupSlug = template.compile(update.groupSlug, update);
+    } else {
+      update.groupSlug = update.groupName;
+    }
+    update.groupSlug = slugify(update.groupSlug, {
       lower: true,
     });
     if (update.updateType === 'major' && update.separateMajorMinor) {