How to Make Confluence space Read-Only
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Having the option to make Confluence space read-only can be very handy for administrators, especially when planning a export/import space on a separate instance.
Environment
- Confluence Data Center
Solutions
You can put your site into read-only mode, to limit what users can do. See Using read-only mode for site maintenance to find out how it works. However, if the requirement is to make space read-only not the whole site, one of the suggested workarounds listed below may work for your space.
Method 1
Revoke all space permissions from all the groups and users. This will prevent users from modifying content or adding comments.
This can be automated by using a third party solution, such as the Confluence CLI tool to remove the permissions across all spaces.
Method 2
The least secure , but rather easy to implement, is obscuring the options altogether.
To disable/hide majorly of page operations for space, navigate to Confluence Administration > Custom HTML, and under Look and Feel add the following to the end of BODY section. This change is instantaneous and does not require a restart.
The custom HTML is modified with the if condition to check the path of the URL by space key. In the below example the scripts will be working for the space key TEST, the other space is not affected by this change.
Please change the path accordingly while adding a new space.
<script type="text/javascript">
AJS.toInit(function() {
if (window.location.pathname.includes('/display/TEST')) {
AJS.$('#editPageLink').hide();
AJS.$('#quick-create-page-button').hide();
AJS.$('#create-page-button').hide();
AJS.$('#action-copy-page-link').hide();
AJS.$('#action-move-page-dialog-link').hide();
AJS.$('#action-remove-content-link').hide();
AJS.$('#header .aui-header .aui-button.aui-button-primary.aui-style').hide();
AJS.$('#comments-section').hide();
AJS.$('#import-word-doc').hide();
AJS.$('#action-copy-page-link').hide();
AJS.$('#action-move-page-dialog-link').hide();
AJS.$('#upload-div').hide();
AJS.$('.removeAttachmentLink').hide();
AJS.$('#action-remove-content-link').hide();
}
});</script>
You can add more spaces by using the || operator into the if condition section or you can add the same block for other spaces. In the below example the scripts will be working for the space key's SS and TS
<script type="text/javascript">
AJS.toInit(function() {
if (window.location.pathname.includes('/display/SS') || window.location.pathname.includes('/display/TS' )) {
AJS.$('#editPageLink').hide();
AJS.$('#quick-create-page-button').hide();
AJS.$('#create-page-button').hide();
AJS.$('#action-copy-page-link').hide();
AJS.$('#action-move-page-dialog-link').hide();
AJS.$('#action-remove-content-link').hide();
AJS.$('#header .aui-header .aui-button.aui-button-primary.aui-style').hide();
AJS.$('#comments-section').hide();
AJS.$('#import-word-doc').hide();
AJS.$('#action-copy-page-link').hide();
AJS.$('#action-move-page-dialog-link').hide();
AJS.$('#upload-div').hide();
AJS.$('.removeAttachmentLink').hide();
AJS.$('#action-remove-content-link').hide();
}
});
</script>