diff --git a/sphinx/htmlhelp.py b/sphinx/htmlhelp.py
index 0742dba98..b3bbd4f63 100644
--- a/sphinx/htmlhelp.py
+++ b/sphinx/htmlhelp.py
@@ -147,7 +147,8 @@ def build_hhx(builder, outdir, outname):
f.write(contents_header)
# special books
f.write('
' + object_sitemap % ('Main page', 'index.html'))
- f.write(' ' + object_sitemap % ('Global Module Index', 'modindex.html'))
+ if builder.config.html_use_modindex:
+ f.write(' ' + object_sitemap % ('Global Module Index', 'modindex.html'))
# the TOC
toc = builder.env.get_and_resolve_doctree(builder.config.master_doc, builder)
def write_toc(node, ullevel=0):