Skip to content

Remove nofollow from product permalink buttons - #66743

Merged
kmanijak merged 5 commits into
woocommerce:trunkfrom
drewmt:fix/product-link-nofollow
Jul 22, 2026
Merged

kmanijak merged 5 commits into
woocommerce:trunkfrom
drewmt:fix/product-link-nofollow

Conversation

@drewmt

@drewmt drewmt commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Submission Review Guidelines:

Changes proposed in this Pull Request:

Product detail links currently receive rel="nofollow" even when they only navigate to the product permalink. This removes nofollow from those links across the client-rendered Product Button, server-rendered blocks, and classic loop templates, while retaining it for cart, direct add-to-cart, and external product links.

Closes #43097.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Add a variable product to a Product Collection and inspect its “Select options” link. Confirm it points to the product permalink without a rel="nofollow" attribute.
  2. Repeat on a classic Shop archive and confirm the product permalink link also omits nofollow.
  3. Inspect a simple product add-to-cart link and an external product link. Confirm both retain nofollow; the external link should also retain noopener noreferrer.

Testing that has already taken place:

  • Product Button Jest tests: 2 passed.
  • Targeted PHP unit tests in wp-env: 10 passed, 18 assertions.
  • Branch-wide JavaScript and PHP lint passed.
  • PHPStan passed for the modified production PHP files.
  • The full block-library TypeScript check was attempted and reports existing trunk-wide type errors unrelated to this change.

Milestone

Note: Check the box above to have the milestone automatically assigned when merged.
Alternatively (e.g. for point releases), manually assign the appropriate milestone.

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

Created manually.

Release Communication

Select if this PR needs a generated summary for release notes:

  • Feature Highlight - For user-facing features (what changed, user impact)
  • Developer Advisory - For developer-facing changes (what changed, how to detect, actions needed)
When to use each?

Feature Highlight: New features, UI changes, or improvements merchants will notice.

  • Example: "New bulk editing for products", "Improved checkout performance"

Developer Advisory: Breaking changes, deprecations, or changes that affect themes/plugins/extensions.

  • Example: "Hook signature change", "Deprecated filter", "REST API field removed"

An AI will analyze your PR and post a draft comment for you to review and edit.

@github-actions github-actions Bot added plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution labels Jul 17, 2026
@drewmt
drewmt marked this pull request as ready for review July 17, 2026 07:45
@woocommercebot
woocommercebot requested review from a team, jorgeatorres, kmanijak and nerrad and removed request for a team July 17, 2026 07:45
@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Testing Guidelines

Hi ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: f7c0c488-a137-4804-9ffc-b45d29b0b36a

📥 Commits

Reviewing files that changed from the base of the PR and between 501c50f and 46524ec.

📒 Files selected for processing (1)
  • plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/button/test/block.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/button/test/block.test.tsx

📝 Walkthrough

Walkthrough

Product button rendering now omits nofollow for product permalink links while retaining it for direct and external add-to-cart destinations. PHP and JavaScript tests cover the updated link attributes and client behavior.

Changes

Product button link attributes

Layer / File(s) Summary
Loop button link attributes
plugins/woocommerce/includes/wc-template-functions.php, plugins/woocommerce/tests/php/includes/wc-template-functions-test.php, plugins/woocommerce/changelog/...
Loop buttons conditionally add rel="nofollow" based on whether the product permalink differs from the add-to-cart URL, with tests for permalink, direct, and external links.
Product button block links
plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php, plugins/woocommerce/tests/php/src/Blocks/BlockTypes/ProductButton.php
Block-rendered links omit nofollow for product permalinks and retain security attributes for direct and external links.
Client AddToCartButton links
plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/button/...
AddToCartButton is exported, updates link event dispatching, removes the permalink nofollow assignment, and adds component tests for product and cart links.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The classic loop template and related PHP render changes extend beyond the linked block-only issue scope. Either narrow the PR to the block fix or add/link an issue that explicitly covers the classic template and PHP render-path changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing nofollow from product permalink buttons.
Description check ✅ Passed The description matches the change set and explains the nofollow behavior update and retained exceptions.
Linked Issues check ✅ Passed The code removes nofollow from product permalink links while keeping it on add-to-cart and external links, matching #43097.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/woocommerce/tests/php/includes/wc-template-functions-test.php`:
- Around line 29-31: Update the output-buffer cleanup block to use a while loop
that repeatedly calls ob_end_clean() while ob_get_level() remains greater than
$buffer_level, ensuring every nested buffer created after the recorded level is
unwound.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: a2e0799d-9c8a-40cb-8ab1-670e477fda02

📥 Commits

Reviewing files that changed from the base of the PR and between 22f4fa9 and f78b613.

📒 Files selected for processing (7)
  • plugins/woocommerce/changelog/fix-product-link-nofollow
  • plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/button/block.tsx
  • plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/button/test/block.test.tsx
  • plugins/woocommerce/includes/wc-template-functions.php
  • plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
  • plugins/woocommerce/tests/php/includes/wc-template-functions-test.php
  • plugins/woocommerce/tests/php/src/Blocks/BlockTypes/ProductButton.php

Comment thread plugins/woocommerce/tests/php/includes/wc-template-functions-test.php Outdated
@nerrad
nerrad removed their request for review July 17, 2026 16:45
@jorgeatorres
jorgeatorres removed the request for review from a team July 20, 2026 17:39

@kmanijak kmanijak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this contribution! This is well scoped PR which I appreciate!

I verified the changes in three scenarios:

  • ✅ classic product grid (shortcode)
  • ✅ All Products block (client-side rendered product button)
  • ✅ Product Collection
    All work as expected.

I left one minor comment about the test file and the setup but otherwise this looks good!

@drewmt

drewmt commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I simplified the test mocks in 46524ec and reran the targeted JS test:

pnpm --filter=@woocommerce/block-library run test:js -- assets/js/atomic/blocks/product-elements/button/test/block.test.tsx --runInBand

It passes locally.

@kmanijak
kmanijak self-requested a review July 21, 2026 11:17

@kmanijak kmanijak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for your contribution and thanks for addressing my feedback, this looks good! 👍

@kmanijak
kmanijak merged commit 39c2b59 into woocommerce:trunk Jul 22, 2026
45 checks passed
@github-actions github-actions Bot added this to the 11.1.0 milestone Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: rel=nofollow on Blocks

2 participants