Test-LocalSiteLinks
Verify that relative links to files and images exist in a Markdown source tree.
Syntax
Test-LocalSiteLinks [-Path] <String> [<CommonParameters>]
Description
Scans a directory tree for Markdown files and Build.json
files. Relative links found in these
files are checked. Broken links are reported. Link checking is not restricted to files in a
static site project generated by New-StaticHTMLSiteProject
, though that is most likely its
primary use.
Parameters
-Path <String>
Path to the root of a directory tree containing Markdown sources. Typically this is the sources directory configured in
Build.json
bymarkdown_dir
. See Static Site Project Customization for more information.
Parameter Property Value Required? true Position? 1 Default value `` Accept pipeline input? false Accept wildcard characters? true
Inputs
None. This function does not read anything from the pipe.
Outputs
Error objects having the following properties:
Property | Description |
---|---|
File |
Path to file containing the proken link. |
Line |
Line number or config option containing the error. |
Link |
The broken link or navigation specification (for Build.jdon files ). |
Error |
Description of the error |
Examples
EXAMPLE 1
Test-LocalSiteLinks -Path E:\lab\...\markdown
Generate a report for broken relative links in Markdown files and
Build.json
files found under theE:\lab\...\markdown
directory tree.The broken links report looks similar to this:
File Line Link Error ---- ---- ---- ----- E:\lab\...\Settings\Manage Settings.md 5 images/RibbonSetting1.png File not found E:\lab\...\Settings\Manage Settings.md 14 Tabs/About Tab.md Malformed url E:\lab\...\Settings\Build.json site_navigation {"Options": "Tabs1"} File not found
The output above shows the theww types of error that are currently recognized:
- The file
RibbonSetting1.png
is not found in theimages
directory next to fileManage Settings.md
- The link
Tabs/About Tab.md
is malformed because urls cannot contain spaces. The link needs to be URL encoded. The correct way ro write this url is:Tabs/About%20Tab.md
- A navigation specification with label
Options
in thesite_navigation
section of the reportedBuild.json
file points to the non-existing file or directoryTabs1
EXAMPLE 2
Test-LocalSiteLinks -Path E:\lab\...\markdown | Out-GridView
Generates a report for broken relative links in Markdown files and
Build.json
files found under theE:\lab\...\markdown
directory tree and opens a dialog window to display the errors.
Related Links
- https://wethat.github.io/MarkdownToHtml/2.7/Test-LocalSiteLinks.html
- Static Site Project Customization
New-StaticHTMLSiteProject
Module: MarkDownToHTML; Version: 2.7.1; (c) 2018-2022 WetHat Lab. All rights reserved.