Plugin to make labels mandatory on every page

Hello,

Is there a way to ensure a label must be entered before publishing or updating a page?
A popup should appear if no label is entered.

First I tried including a JavaScript in custom HTML:

<script type="text/javascript" src="/confluence/includes/js/label_alert.js"></script>

At the moment the script looks like this:

&lt;script type="text/javascript"&gt;
AJS.toInit(function(){
   AJS.$('#rte-button-publish').click(function(e){
      alert("Please add at least one or more labels");
   });
});
&lt;/script&gt;

I have the code from this post: https://community.atlassian.com/t5/Confluence-questions/Mandatory-labels-in-Confluence/qaq-p/39597

Since it is the first time that I do something with custom html and javascript, I do not know if it is correct at all. In any case, I don’t get any alerts.

I am now trying to develop my own plugin.
Can you guide me in the right way so that I habe a good start and can achieve my goal?

I would be grateful for any help!

Hello Florian,

Not an answer, but generally “only” JavaScript/HTML is not a bulletproof solution as it doesn’t force the requirement on the server side, but probably works for most users.

You may have a look at, maybe this has such a feature: https://marketplace.atlassian.com/apps/142/comala-document-management

We also have this as a feature request for our https://marketplace.atlassian.com/apps/1213350/label-suggester-for-confluence?hosting=server&tab=overview but still not done anything in this direction.