metalsmith / permalinks

A Metalsmith plugin for permalinks.
MIT License
62 stars 67 forks source link

Generate an SEO inner link when we don't need it #128

Closed SEWeiTung closed 2 years ago

SEWeiTung commented 2 years ago

Describe the bug When set "permalinks" to false in an md file, there's something wrong in its "link rel".

To Reproduce

  1. Download the nodejs.org project and run npm i with the latest version of nodejs (Refs: https://github.com/nodejs/nodejs.org).
  2. Build it by running "npm run build" and wait for several seconds until all the pages are generated.
  3. Open any "404.html" file under a language folder such as "en", you'll find this:
    <link rel="canonical" href="https://nodejs.org/en/404.md/">

Expected behaviour

DO NOT GENERATE ANY LINKS FOR SEO IF WE DON'T NEED IT.

Additional context

PS:Maybe we should decide to let users set whether the specific pages can be SEO or not (default is 'true', but for some very special cases such as an error page, SEO doesn't need, so the link shouldn't be added in the generated page ).

I suspect the problem is because when "permalinks = false" , the original route WON'T BE REPLACED but to keep what it was? See: https://github.com/metalsmith/permalinks/blob/5faed4cf22a802bc9de667d0e43a68438e2b0fe2/lib/index.js#L312

webketje commented 2 years ago

permalinks does not render any HTML, that is done by the templating, see https://github.com/nodejs/nodejs.org/blob/main/layouts/partials/html-head.hbs#L33. permalinks is not used with the "false" value set in the codebase you referred to. Nevertheless the correct path would be /en/404 instead of /en/404.md. That can only be done by running layouts before permalinks.

webketje commented 2 years ago

Closing as stale