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

fix(sitemap): exclude pages with robots noindex from sitemap #7143

Merged
merged 3 commits into from
Apr 14, 2022

Conversation

Josh-Cena
Copy link
Collaborator

Motivation

fix #6247. I'm not sure if providing the entire helmet state would be too big as part of the plugin API, but currently it's the only way to get structured data about the head state. Otherwise, we can only export a string and then parse it again in postBuild, which sounds like too much overhead.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

I reverted #7122 and added <meta name="robots" content="noindex" /> to the debug layout. It turns out that these routes are still not included in the sitemap.

@Josh-Cena Josh-Cena added the pr: bug fix This PR fixes a bug in a past release. label Apr 9, 2022
@Josh-Cena Josh-Cena requested review from slorber and lex111 as code owners April 9, 2022 14:31
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 9, 2022
@netlify
Copy link

netlify bot commented Apr 9, 2022

[V2]

Name Link
🔨 Latest commit 4f3d7b3
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6257781b65fa6900080ca5b3
😎 Deploy Preview https://deploy-preview-7143--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Apr 9, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 66
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

Lighthouse ran on https://deploy-preview-7143--docusaurus-2.netlify.app/

@github-actions
Copy link

github-actions bot commented Apr 9, 2022

Size Change: -25 B (0%)

Total Size: 798 kB

ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 50 kB 0 B
website/build/assets/css/styles.********.css 106 kB 0 B
website/build/assets/js/main.********.js 604 kB -25 B (0%)
website/build/index.html 38.6 kB 0 B

compressed-size-action

@Josh-Cena Josh-Cena added the status: awaiting review This PR is ready for review, will be merged after maintainers' approval label Apr 9, 2022
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

That looks to work nicely

Not fan of "helmet" name + public API surface, which makes it complex to document (also doc is missing)

@@ -9,8 +9,6 @@ import type {LoadContext, Plugin} from '@docusaurus/types';
import {docuHash, normalizeUrl, posixPath} from '@docusaurus/utils';
import path from 'path';

export const routeBasePath = '__docusaurus/debug';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't it make sense to keep this part?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least not as a public API. I also don't find this abstraction particularly useful

packages/docusaurus-plugin-sitemap/src/createSitemap.ts Outdated Show resolved Hide resolved
packages/docusaurus-plugin-sitemap/src/createSitemap.ts Outdated Show resolved Hide resolved
await plugin.postBuild({...props, content: plugin.content});
await plugin.postBuild({
...props,
helmet: headTags,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to head or headTags?

Not fan of using "helmet" name here, lib is an implementation detail and we already use "head" name in other places

Also not fan of the API surface it introduces.

Users shouldn't use something like helmet[route]?.meta.toComponent(), this is a quite confusing that we'd struggle to document well and ensure retrocompatibility on.

Maybe we could only expose a few route attributes and transform all HelmetDatum types to a convenient format, easy to document?

packages/docusaurus/src/commands/build.ts Outdated Show resolved Hide resolved
@Josh-Cena
Copy link
Collaborator Author

Not a fan of the API design either, but I can't find a nicer abstraction of the helmet state in a structured way.

@Josh-Cena Josh-Cena force-pushed the jc/sitemap-exclude-noindex branch from 759d867 to 4f3d7b3 Compare April 14, 2022 01:25
@slorber
Copy link
Collaborator

slorber commented Apr 14, 2022

Not a fan of the API design either, but I can't find a nicer abstraction of the helmet state in a structured way.

I suggest we move on and merge this as it's a nice improvement for internal usage in the sitemaps plugin

We can document this behind an experimental flag, warn it may change and recommend to use "head" only in site plugins, not public/open-source plugins?

We don't flag any feature as experimental for now but we probably could as we have a few undocumented apis (like useRouteContext)

@Josh-Cena
Copy link
Collaborator Author

We also have a routes prop passed to postBuild that's undocumented. Maybe we'll eventually remove that

@slorber
Copy link
Collaborator

slorber commented Apr 14, 2022

We also have a routes prop passed to postBuild that's undocumented. Maybe we'll eventually remove that

🤷‍♂️ we might as well keep routes and assign the rendered metadata to items instead of having a separate object with head metadata. Both work, I just don't know what is more convenient to use (considering routes are deeply nested, metadata would only be added to the leaves final routes)

@slorber
Copy link
Collaborator

slorber commented Apr 14, 2022

I guess we can keep all this undocumented for now, let's merge as is 👍

Hopefull if someone plans to use this they'll reach out and explain their use-case

@slorber slorber merged commit 03516dc into main Apr 14, 2022
@slorber slorber deleted the jc/sitemap-exclude-noindex branch April 14, 2022 09:31
@Josh-Cena Josh-Cena removed the status: awaiting review This PR is ready for review, will be merged after maintainers' approval label Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pages with noindex meta still showing in sitemap
3 participants