diff --git a/CHANGES.md b/CHANGES.md
index 2ab94311f176c6d761b892ffdb13a260fee4b684..0375fc24fc99626fa922e0323a569580c238d7b1 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,7 @@ Changes
 
 ### Unreleased
 
+* 2021-08-16 - Improvement: Add in-course settings only to HTML tree of the setting is enabled.
 * 2021-08-16 - Adjust activity_settings_incourse.mustache template based on changes in settings_link_page.mustache
 * 2021-08-16 - Improvement: Adjusted tab appearance for in-course settings.
 * 2021-08-16 - Adjusted settings_link_page.mustache template due to upstream changes in theme Boost.
diff --git a/scss/post.scss b/scss/post.scss
index 1f82410359219e7d34a2d4c9087d9dfcf640bee5..17c3301254d32a8a876b3bab803fc047f55fd7e7 100644
--- a/scss/post.scss
+++ b/scss/post.scss
@@ -948,53 +948,55 @@ body.scrolled #goto-top-link {
 }
 
 /* In-course settings. */
-#boost-campus-course-settings,
-#boost-campus-activity-settings {
-    /* Initially do not display the settings. Visibility will be changed on click with incoursesettings.js. */
-    display: none;
+@if (variable-exists(showsettingsincourse)) {
+    #boost-campus-course-settings,
+    #boost-campus-activity-settings {
+        /* Initially do not display the settings. Visibility will be changed on click with incoursesettings.js. */
+        display: none;
 
-    /* Improve layout and look of the settings as they are now placed within the page header. */
-    margin-bottom: 1rem;
-    .tab-content .card {
-        border: none;
-    }
+        /* Improve layout and look of the settings as they are now placed within the page header. */
+        margin-bottom: 1rem;
+        .tab-content .card {
+            border: none;
+        }
 
-    /* Improve styling of the tabs so that they look more like real tabs. */
-    .nav-tabs {
-        border: none;
-    }
-    .tab-content .card {
-        background-color: darken($body-bg, 5%);
-    }
+        /* Improve styling of the tabs so that they look more like real tabs. */
+        .nav-tabs {
+            border: none;
+        }
+        .tab-content .card {
+            background-color: darken($body-bg, 5%);
+        }
 
-    /* Do some more tweaks on smaller screens and bigger screens differently as Moodle uses different styles. */
-    @include media-breakpoint-up(md) {
-        /* Add some space. */
-        padding: 0 1rem 1.3rem 1rem;
+        /* Do some more tweaks on smaller screens and bigger screens differently as Moodle uses different styles. */
+        @include media-breakpoint-up(md) {
+            /* Add some space. */
+            padding: 0 1rem 1.3rem 1rem;
 
-        /* Highlight the active tab. */
-        .nav-tabs {
-            .active {
-                background-color: darken($body-bg, 5%);
-                border-color: darken($body-bg, 5%);
+            /* Highlight the active tab. */
+            .nav-tabs {
+                .active {
+                    background-color: darken($body-bg, 5%);
+                    border-color: darken($body-bg, 5%);
+                }
             }
         }
-    }
-    @include media-breakpoint-down(sm) {
-        /* Add some space. */
-        padding: 1rem 0 1.3rem 0;
+        @include media-breakpoint-down(sm) {
+            /* Add some space. */
+            padding: 1rem 0 1.3rem 0;
 
-        /* Remove the border around the course settings card as it would be incomplete. */
-        &.card {
-            border: none;
+            /* Remove the border around the course settings card as it would be incomplete. */
+            &.card {
+                border: none;
+            }
         }
-    }
 
-}
+    }
 
-/* As this is already placed within the activity content card, the border around the settings card should be removed. */
-#boost-campus-activity-settings {
-    border: none;
+    /* As this is already placed within the activity content card, the border around the settings card should be removed. */
+    #boost-campus-activity-settings {
+        border: none;
+    }
 }
 
 /* Setting to move 'Switch role to...' menu item to the course settings - but only if
diff --git a/templates/columns2.mustache b/templates/columns2.mustache
index 0219afd764f4afc76afa06e4d7412e0b478540d6..c8624122e0f62118928cd00153cbd1ae62bf106c 100644
--- a/templates/columns2.mustache
+++ b/templates/columns2.mustache
@@ -114,9 +114,11 @@
 
         <div id="page-content" class="row pb-3 d-print-block">
             <div id="region-main-box" class="col-12">
-                {{#node}}
-                    {{> theme_boost_campus/settings_link_page }}
-                {{/node}}
+                {{#incoursesettings}}
+                    {{#node}}
+                        {{> theme_boost_campus/settings_link_page }}
+                    {{/node}}
+                {{/incoursesettings}}
                 {{#hasregionmainsettingsmenu}}
                 <div id="region-main-settings-menu" class="d-print-none {{#hasblocks}}has-blocks{{/hasblocks}}">
                     <div> {{{ output.region_main_settings_menu }}} </div>
@@ -128,9 +130,11 @@
                         <div class="region_main_settings_menu_proxy"></div>
                     {{/hasregionmainsettingsmenu}}
                     {{{ output.course_content_header }}}
-                    {{#activitynode}}
-                        {{> theme_boost_campus/activity_settings_incourse }}
-                    {{/activitynode}}
+                    {{#incoursesettings}}
+                        {{#activitynode}}
+                            {{> theme_boost_campus/activity_settings_incourse }}
+                        {{/activitynode}}
+                    {{/incoursesettings}}
                     {{{ output.main_content }}}
                     {{{ output.activity_navigation }}}
                     {{{ output.course_content_footer }}}