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

Check for redirects? #20

Open
ryangittings opened this issue Apr 2, 2020 · 5 comments
Open

Check for redirects? #20

ryangittings opened this issue Apr 2, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@ryangittings
Copy link

Hey,

Is it possible to look at Netlify redirects, as the plugin checks for some links that have 301 redirects on, but are marked as broken.

Great plugin!

Cheers.

@Munter
Copy link
Owner

Munter commented Apr 6, 2020

That's a good idea.

I'd still not recommend linking to a resource you know for certain is a permanent redirect, but the plugin certainly shouldn't flag it as non-existing

@Munter Munter added the enhancement New feature or request label Apr 6, 2020
@ryangittings
Copy link
Author

Exactly. It stopped my build from deploying, I had to fix some really old links (good practice as you say), but don't think it should stop it from deploying in this specific case.

@Munter
Copy link
Owner

Munter commented Apr 7, 2020

I looked a bit into what code is available from netlify to extract that information. It's not a setup I'd like to depend on it its current form. But eventually there will be utilities to provide the data set for this feature.

Blocked, waiting for netlify/build#217

@mojavelinux
Copy link

I'm running into the same problem. The index page for my site is a redirect to a concrete "home" page. For various reasons, this can't be an HTML file. However, every page links to it (from the header). As a result the checklinks plugin reports it as a failure.

I'd be fine if I could supply a list of these locations that would be added to the set of available HTML files that hyperlink checks (sort of the inverse of skip patterns).

For now, I touch the index.html file at the end of the build command, then make sure to use the force flag on my redirect rule so the file is ultimately ignored by the web server.

@olliebennett
Copy link

olliebennett commented Jun 23, 2021

It seems the netlify-redirect-parser is under active development; not sure whether that helps facilitate a resolution for this issue, but fingers crossed it does.

I've said it before but this plugin is great; thanks. It's caught various typos etc. in the past and saved many 404s!

To add my use case (if useful); I'm setting up a proxy for Plausible analytics - following their guide. The purpose for redirects, in this case, is to rewrite requests for /js/script.js to plausible's servers, thus bypassing any adblockers.

My netlify.toml is shared below. Commenting out this plugin (as shown) resolves the deployment crash, and the redirects work correctly.

[build.processing.html]
  pretty_urls = true

# [[plugins]]
# package = "netlify-plugin-checklinks"
#
#   [plugins.inputs]
#
#   # An array of glob patterns for pages on your site
#   # Recursive traversal will start from these
#   entryPoints = [
#     "*.html",
#   ]
#
#   recursive = true

# Redirect default Netlify subdomain to primary domain
[[redirects]]
  from = "https://mydomain.netlify.app/*"
  to = "https://www.mydomain.com/:splat"
  force = true

# Redirect for Plausible Analytics script
[[redirects]]
  from = "/a/js/script.js"
  to = "https://plausible.io/js/plausible.js"
  status = 200

# Redirect for Plausible Analytics API calls
[[redirects]]
  from = "/a/api/event"
  to = "https://plausible.io/api/event"
  status = 202

My <head> includes the line;

<script defer data-domain="mydomain.com" data-api="/a/api/event" src="/a/js/script.js"></script>

... which is what the checklinks plugin catches and flags as an invalid URL (i.e. /a/js/script.js doesn't exist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants