Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration strict option not checking broken links #738

Closed
timorjim opened this issue Oct 13, 2015 · 13 comments
Closed

Configuration strict option not checking broken links #738

timorjim opened this issue Oct 13, 2015 · 13 comments
Labels
Bug
Milestone

Comments

@timorjim
Copy link

@timorjim timorjim commented Oct 13, 2015

I was testing mkdocs earlier this year and was using "strict: true" in my mkdocs.yml. If I recall correctly, it was working then and building would break if there was a broken link in the .md.

However I am now using v0.14.0 and this config option seems to have no effect on the build - I get no warnings or errors when building regardless of the value of strict.

@d0ugal d0ugal added the Enhancement label Feb 22, 2016
@d0ugal
Copy link
Member

@d0ugal d0ugal commented Feb 22, 2016

Sorry, this one got lost somewhere along the way. This feature is working for me. We would need debug help - have you tried the most recent version? do you get any errors? what python version and OS are you running?

I'll close this now as it is so old and seems to be working, but happy for a new issue to be opened or I'll reopen this one.

@d0ugal d0ugal closed this Feb 22, 2016
@nguillaumin
Copy link

@nguillaumin nguillaumin commented Aug 3, 2016

I think I'm seeing a similar issue. I'm getting a warning, but the build is not halted as the doco says it should.

I'm using MkDocs 0.15.3, Python 3.5.2. My YML file is:

site_name: Documentation
theme_dir: 'fb_theme'
copyright: 'Copyright © 2016'
strict: true
extra:
# REDACTED

When I run mkdocs serve:

INFO    -  Building documentation... 
DEBUG   -  Loading configuration file: REDACTED/mkdocs.yml 
DEBUG   -  Config value: 'site_author' = None 
DEBUG   -  Config value: 'site_description' = None 
DEBUG   -  Config value: 'include_nav' = True 
DEBUG   -  Config value: 'site_url' = None 
DEBUG   -  Config value: 'google_analytics' = None 
DEBUG   -  Config value: 'include_next_prev' = True 
DEBUG   -  Config value: 'mdx_configs' = {} 
DEBUG   -  Config value: 'site_dir' = 'REDACTED/site' 
DEBUG   -  Config value: 'mkdocs_templates' = '/usr/lib/python3.5/site-packages/mkdocs/templates' 
DEBUG   -  Config value: 'theme_dir' = ['REDACTED/fb_theme', '/usr/lib/python3.5/site-packages/mkdocs/assets/search'] 
DEBUG   -  Config value: 'use_directory_urls' = True 
DEBUG   -  Config value: 'repo_url' = None 
DEBUG   -  Config value: 'strict' = False 
DEBUG   -  Config value: 'pages' = ['index.md', {

[...] (too many pages)

DEBUG   -  Config value: 'markdown_extensions' = ['meta', 'toc', 'tables', 'fenced_code'] 
DEBUG   -  Config value: 'extra_templates' = [] 
DEBUG   -  Config value: 'config_file_path' = 'REDACTED/mkdocs.yml' 
DEBUG   -  Config value: 'theme' = 'mkdocs' 
DEBUG   -  Config value: 'dev_addr' = '127.0.0.1:8000' 
DEBUG   -  Config value: 'repo_name' = None 
DEBUG   -  Config value: 'site_favicon' = None 
DEBUG   -  Config value: 'extra_css' = [] 
DEBUG   -  Config value: 'site_name' = 'Documentation' 
DEBUG   -  Config value: 'docs_dir' = 'REDACTED/docs' 
DEBUG   -  Config value: 'extra_javascript' = [] 
DEBUG   -  Config value: 'remote_branch' = 'gh-pages' 
DEBUG   -  Config value: 'copyright' = 'Copyright © 2016' 
DEBUG   -  Config value: 'remote_name' = 'origin' 
DEBUG   -  Config value: 'extra' = redacted
INFO    -  Cleaning site directory 
DEBUG   -  Copying static assets from theme: /usr/lib/python3.5/site-packages/mkdocs/assets/search 
DEBUG   -  Copying static assets from theme: REDACTED/fb_theme 
DEBUG   -  Copying static assets from the docs dir. 
DEBUG   -  Building markdown pages. 
DEBUG   -  Building template: 404.html 
DEBUG   -  Building template: search.html 
DEBUG   -  Search is enabled but the theme doesn't contain a search.html file. Assuming the theme implements search within a modal. 
DEBUG   -  Building template: sitemap.xml 
DEBUG   -  Building extra_templates page 
DEBUG   -  Building page index.md 
WARNING -  The page "index.md" contained a hyperlink to "Something.md" which is not listed in the "pages" configuration. 
DEBUG   -  Building page administer/administer-introduction.md 
DEBUG   -  Building page administer/diagnostics/download-support-package.md 
DEBUG   -  Building page administer/diagnostics/system-diagnostic.md 
...

I get the warning, but the build continues.

@nguillaumin
Copy link

@nguillaumin nguillaumin commented Aug 3, 2016

Hm, it works with mkdocs build though, so I guess this is expected for serve to not halt the build? If that's the case please disregard my comment.

@nguillaumin
Copy link

@nguillaumin nguillaumin commented Aug 3, 2016

Erm... ok so, actually, it doesn't work 😉

  • Setting strict: true in mkdocs.yml does NOT halt the build on broken links
  • Using mkdocs build -s does
@waylan
Copy link
Member

@waylan waylan commented Aug 3, 2016

  • Setting strict: true in mkdocs.yml does NOT halt the build on broken links
  • Using mkdocs build -s does

@nguillaumin thanks for the clear report. I can confirm that I get the same behavior and am reopening this issue.

BTW, I also noticed that this only applies to *.md internal links. For example, when testing this, I noticed that the index.md file in MkDocs documentation contains links to both user-guide/deploying-your-docs/ and user-guide/deploying-your-docs.md (which in itself, is a separate issue in need to fixing -- see markdownlint/markdownlint#137). The former does not raise a warning and the later does when the links are altered to be inaccurate (when testing I removed the final dash: user-guide/deploying-yourdocs/ and user-guide/deploying-yourdocs.md).

@waylan waylan reopened this Aug 3, 2016
@waylan waylan added this to the 0.16 milestone Aug 3, 2016
@waylan waylan added Bug and removed Enhancement labels Aug 3, 2016
@waylan
Copy link
Member

@waylan waylan commented Aug 3, 2016

Ahh, when the --strict flag is not included, then is evaluates to False and is passed in by the CLI overriding the value in the config file. Of course, when if the flag is included, it evaluated to True and no problem occurs. So we need to not pass the script value to the config from the CLI if the flag is not True. Not sure if Click has a way to do that or if we need to special case it in the code

waylan added a commit to waylan/mkdocs that referenced this issue Aug 3, 2016
waylan added a commit to waylan/mkdocs that referenced this issue Aug 3, 2016
waylan added a commit to waylan/mkdocs that referenced this issue Aug 4, 2016
@waylan waylan closed this in #1009 Aug 4, 2016
@nguillaumin
Copy link

@nguillaumin nguillaumin commented Aug 4, 2016

Thanks! 🏆

@fkromer
Copy link

@fkromer fkromer commented Nov 27, 2016

Does the link checking also work for external links?

I inserted a broken external link into the docs. I have set the config value strict: True in mkdocs.yml and run mkdocs build or mkdocs serve but the build does not break and also not warn or error about the link. I also tried mkdocs build -s and mkdocs build --strict (mkdocs 0.16.0) with the same result...

@waylan
Copy link
Member

@waylan waylan commented Nov 27, 2016

@fkromer no, checking external links is beyond the scope of our validator. Perhaps that could be addressed as a Plugin when we implement the API (see #206).

@fkromer
Copy link

@fkromer fkromer commented Nov 27, 2016

@waylan a plugin API would be great!

@davidhrbac
Copy link
Contributor

@davidhrbac davidhrbac commented Feb 3, 2017

@fkromer you can check external links with https://github.com/dkhamsing/awesome_bot like this:

find . -name '*.md' -exec grep -l http {} + | xargs awesome_bot -t 10 --allow-dupe --allow-redirect
@fkromer
Copy link

@fkromer fkromer commented Feb 3, 2017

@davidhrbac Thanks for that hint 👍

@jaxxzer
Copy link

@jaxxzer jaxxzer commented Feb 11, 2019

I found https://github.com/magicmatatjahu/milv to work better than awesome_bot, especially for checking internal links and anchors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants