statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.64k stars 236 forks source link

ValidateRelativeLinks seems to just list all my links #861

Closed SilentSin closed 2 years ago

SilentSin commented 4 years ago

Perhaps I'm misunderstanding the purpose of DocsKeys.ValidateRelativeLinks. I expected it to check that the target of each link actually exists and list any that don't so I can fix them, but it seems to just list all my links on every page (including references to images which are right next to the page itself).

daveaglick commented 4 years ago

Your understanding is correct. The module should just be reporting relative links that don't exist in the output.

The module works by checking files on disk in the output folder: https://github.com/Wyamio/Wyam/blob/master/src/extensions/Wyam.Html/ValidateLinks.cs#L232 - is it possible you're running it in a manual pipeline before the WriteFiles module(s) get called? If so, it's recommended to move ValidateLinks to a separate pipeline after all files have been written.

If you're just running the stock docs recipe then something is wrong. Are you using a Keys.LinkRoot?

SilentSin commented 4 years ago

I'm just using the regular docs recipe without any pipeline customisations.

My website is hosted at https://kybernetikgames.github.io/animancer/ so I'm using:

Settings[Keys.Host] = "kybernetikgames.github.io";
Settings[Keys.LinkRoot] = "/animancer/";

I just tried without the slashes and without the LinkRoot entirely but neither seemed to affect this issue.

Here's my full config file:

#recipe Docs

// Customize your settings and add new ones here
Settings[DocsKeys.Title] = "Animancer";
Settings[Keys.Host] = "kybernetikgames.github.io";
Settings[Keys.LinkRoot] = "/animancer/";
Settings[Keys.LinksUseHttps] = true;
Settings[Keys.UseCache] = true;
Settings[DocsKeys.ValidateRelativeLinks] = true;

Settings[DocsKeys.SolutionFiles] = "../Project/Animancer.sln";
Settings[DocsKeys.IncludeGlobalNamespace] = false;
Settings[DocsKeys.ImplicitInheritDoc] = true;

Settings[Keys.DateTimeDisplayCulture] = "en-AU";
Settings[DocsKeys.IncludeDateInPostPath] = true;

// Add any pipeline customizations here
daveaglick commented 4 years ago

Perfect, thanks - that definitely gives me something to go on. This is clearly a bug.

daveaglick commented 2 years ago

I'm slowly working on cleaning up some of the issues that came over from Wyam. Since this one is pretty old and I'm pretty sure it's resolved, I'm going to go ahead and close it. Please don't hesitate to comment or open a new one if it turns out this issue is still relevant in Statiq.