diff --git a/sphinx_gallery/gen_gallery.py b/sphinx_gallery/gen_gallery.py
index 9d8aadd..1a93db0 100644
--- a/sphinx_gallery/gen_gallery.py
+++ b/sphinx_gallery/gen_gallery.py
@@ -258,7 +258,7 @@ def generate_gallery_rst(app):
 
     # Check for duplicate filenames to make sure linking works as expected
     examples_dirs = [ex_dir for ex_dir, _ in workdirs]
-    files = collect_gallery_files(examples_dirs)
+    files = collect_gallery_files(examples_dirs, gallery_conf)
     check_duplicate_filenames(files)
 
     for examples_dir, gallery_dir in workdirs:
@@ -549,14 +549,16 @@ def summarize_failing_examples(app, exception):
                          "\n" + "-" * 79)
 
 
-def collect_gallery_files(examples_dirs):
+def collect_gallery_files(examples_dirs, gallery_conf):
     """Collect python files from the gallery example directories."""
     files = []
     for example_dir in examples_dirs:
         for root, dirnames, filenames in os.walk(example_dir):
             for filename in filenames:
                 if filename.endswith('.py'):
-                    files.append(os.path.join(root, filename))
+                    if re.search(gallery_conf['ignore_pattern'],
+                                 filename) is None:
+                        files.append(os.path.join(root, filename))
     return files
 
 
diff --git a/sphinx_gallery/gen_rst.py b/sphinx_gallery/gen_rst.py
index 5d632a5..4100482 100644
--- a/sphinx_gallery/gen_rst.py
+++ b/sphinx_gallery/gen_rst.py
@@ -857,12 +857,13 @@ def save_rst_example(example_rst, example_file, time_elapsed,
 
     binder_text = (" or to run this example in your browser via Binder"
                    if len(binder_conf) else "")
-    example_rst = (".. note::\n"
-                   "    :class: sphx-glr-download-link-note\n\n"
-                   "    Click :ref:`here <sphx_glr_download_{0}>` "
-                   "to download the full example code{1}\n"
-                   ".. rst-class:: sphx-glr-example-title\n\n"
-                   ".. _sphx_glr_{0}:\n\n"
+    example_rst = (".. only:: html\n\n"
+                   "    .. note::\n"
+                   "        :class: sphx-glr-download-link-note\n\n"
+                   "        Click :ref:`here <sphx_glr_download_{0}>` "
+                   "    to download the full example code{1}\n"
+                   "    .. rst-class:: sphx-glr-example-title\n\n"
+                   "    .. _sphx_glr_{0}:\n\n"
                    ).format(ref_fname, binder_text) + example_rst
 
     if time_elapsed >= gallery_conf["min_reported_time"]:

diff --git a/sphinx_gallery/tests/test_gen_gallery.py b/sphinx_gallery/tests/test_gen_gallery.py
index 872bb83..9f5269d 100644
--- a/sphinx_gallery/tests/test_gen_gallery.py
+++ b/sphinx_gallery/tests/test_gen_gallery.py
@@ -281,7 +281,7 @@ def test_example_sorting_title(sphinx_app_wrapper):
     _check_order(sphinx_app, 'title')
 
 
-def test_collect_gallery_files(tmpdir):
+def test_collect_gallery_files(tmpdir, gallery_conf):
     """Test that example files are collected properly."""
     rel_filepaths = ['examples/file1.py',
                      'examples/test.rst',
@@ -298,7 +298,7 @@ def test_collect_gallery_files(tmpdir):
 
     examples_path = tmpdir.join('examples')
     dirs = [examples_path.strpath]
-    collected_files = set(collect_gallery_files(dirs))
+    collected_files = set(collect_gallery_files(dirs, gallery_conf))
     expected_files = set(
         [ap.strpath for ap in abs_paths
          if re.search(r'examples.*\.py$', ap.strpath)])
@@ -307,13 +307,35 @@ def test_collect_gallery_files(tmpdir):
 
     tutorials_path = tmpdir.join('tutorials')
     dirs = [examples_path.strpath, tutorials_path.strpath]
-    collected_files = set(collect_gallery_files(dirs))
+    collected_files = set(collect_gallery_files(dirs, gallery_conf))
     expected_files = set(
         [ap.strpath for ap in abs_paths if re.search(r'.*\.py$', ap.strpath)])
 
     assert collected_files == expected_files
 
 
+def test_collect_gallery_files_ignore_pattern(tmpdir, gallery_conf):
+    """Test that ignore pattern example files are not collected."""
+    rel_filepaths = ['examples/file1.py',
+                     'examples/folder1/fileone.py',
+                     'examples/folder1/file2.py',
+                     'examples/folder2/fileone.py']
+
+    abs_paths = [tmpdir.join(rp) for rp in rel_filepaths]
+    for ap in abs_paths:
+        ap.ensure()
+
+    gallery_conf['ignore_pattern'] = r'one'
+    examples_path = tmpdir.join('examples')
+    dirs = [examples_path.strpath]
+    collected_files = set(collect_gallery_files(dirs, gallery_conf))
+    expected_files = set(
+        [ap.strpath for ap in abs_paths
+         if re.search(r'one', ap.strpath) is None])
+
+    assert collected_files == expected_files
+
+
 @pytest.mark.conf_file(content="""
 sphinx_gallery_conf = {
     'backreferences_dir' : os.path.join('modules', 'gen'),
diff --git a/sphinx_gallery/tests/test_gen_rst.py b/sphinx_gallery/tests/test_gen_rst.py
index 911fc6c..d0d0602 100644
--- a/sphinx_gallery/tests/test_gen_rst.py
+++ b/sphinx_gallery/tests/test_gen_rst.py
@@ -417,6 +417,16 @@ def test_remove_config_comments(gallery_conf):
     assert '# sphinx_gallery_thumbnail_number = 1' not in rst
 
 
+def test_download_link_note_only_html(gallery_conf):
+    """Test html only directive for download_link."""
+    rst = _generate_rst(gallery_conf, 'test.py', CONTENT)
+    download_link_note = (".. only:: html\n\n"
+                          "    .. note::\n"
+                          "        :class: sphx-glr-download-link-note\n\n"
+                          )
+    assert download_link_note in rst
+
+
 @pytest.mark.parametrize('ext', ('.txt', '.rst', '.bad'))
 def test_gen_dir_rst(gallery_conf, fakesphinxapp, ext):
     """Test gen_dir_rst."""

check_duplicated does not respect the ignore_pattern
It seems that check_duplicate_filenames does not respect the ignore_pattern.

The proper fix would probably be to have collect_gallery_files respect the ignore_pattern.
sphinx_gallery/tests/test_gen_gallery.py::test_collect_gallery_files sphinx_gallery/tests/test_gen_gallery.py::test_collect_gallery_files_ignore_pattern sphinx_gallery/tests/test_gen_rst.py::test_download_link_note_only_html
sphinx_gallery/tests/test_gen_gallery.py::test_default_config sphinx_gallery/tests/test_gen_gallery.py::test_no_warning_simple_config sphinx_gallery/tests/test_gen_gallery.py::test_config_old_backreferences_conf sphinx_gallery/tests/test_gen_gallery.py::test_config_backreferences sphinx_gallery/tests/test_gen_gallery.py::test_duplicate_files_warn sphinx_gallery/tests/test_gen_gallery.py::test_example_sorting_default sphinx_gallery/tests/test_gen_gallery.py::test_example_sorting_filesize sphinx_gallery/tests/test_gen_gallery.py::test_example_sorting_filename sphinx_gallery/tests/test_gen_gallery.py::test_example_sorting_title sphinx_gallery/tests/test_gen_gallery.py::test_binder_copy_files sphinx_gallery/tests/test_gen_gallery.py::test_expected_failing_examples_were_executed sphinx_gallery/tests/test_gen_gallery.py::test_write_computation_times_noop sphinx_gallery/tests/test_gen_rst.py::test_split_code_and_text_blocks sphinx_gallery/tests/test_gen_rst.py::test_bug_cases_of_notebook_syntax sphinx_gallery/tests/test_gen_rst.py::test_direct_comment_after_docstring sphinx_gallery/tests/test_gen_rst.py::test_final_rst_last_word sphinx_gallery/tests/test_gen_rst.py::test_rst_block_after_docstring sphinx_gallery/tests/test_gen_rst.py::test_rst_empty_code_block sphinx_gallery/tests/test_gen_rst.py::test_script_vars_globals sphinx_gallery/tests/test_gen_rst.py::test_codestr2rst sphinx_gallery/tests/test_gen_rst.py::test_extract_intro_and_title sphinx_gallery/tests/test_gen_rst.py::test_md5sums sphinx_gallery/tests/test_gen_rst.py::test_fail_example sphinx_gallery/tests/test_gen_rst.py::test_custom_scraper_thumbnail_alpha sphinx_gallery/tests/test_gen_rst.py::test_remove_config_comments sphinx_gallery/tests/test_gen_rst.py::test_gen_dir_rst[.txt] sphinx_gallery/tests/test_gen_rst.py::test_gen_dir_rst[.rst] sphinx_gallery/tests/test_gen_rst.py::test_gen_dir_rst[.bad] sphinx_gallery/tests/test_gen_rst.py::test_pattern_matching sphinx_gallery/tests/test_gen_rst.py::test_thumbnail_number[# sphinx_gallery/tests/test_gen_rst.py::test_thumbnail_number[#sphinx_gallery_thumbnail_number sphinx_gallery/tests/test_gen_rst.py::test_thumbnail_number[ sphinx_gallery/tests/test_gen_rst.py::test_zip_notebooks sphinx_gallery/tests/test_gen_rst.py::test_rst_example sphinx_gallery/tests/test_gen_rst.py::test_output_indentation sphinx_gallery/tests/test_gen_rst.py::test_empty_output_box sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[assign,()] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[var,()] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[print(var),()] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[print+var,()] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[assign,(repr)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[var,(repr)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[print(var),(repr)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[print+var,(repr)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[repr_and_html,(repr)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[print sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[repr_only,(html)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[repr_and_html,(html)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[repr_and_html,(html,repr)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[repr_and_html,(repr,html)] sphinx_gallery/tests/test_gen_rst.py::test_capture_repr[repr_only,(html,repr)]