-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add SEO tweaks #491
base: master
Are you sure you want to change the base?
Add SEO tweaks #491
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe recent updates introduce new functionality to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- extension.json (1 hunks)
- includes/Hooks.php (7 hunks)
Additional Context Used
Path-based Instructions (1)
includes/Hooks.php (1)
Pattern
**/*.php
: Follow MediaWiki PHP Coding Standards:Indentation:
- Use tabs for indentation, not spaces.
Spaces:
- Use spaces on either side of binary operators.
Example: $a = $b + $c; (Correct) $a=$b+$c; (Incorrect)- Add spaces inside parentheses, except where they are empty.
Example: $a = getFoo( $b ); (Correct) $a = getFoo($b); (Incorrect)- Do not add a space after a function name.
Example: $c = getBar(); (Correct) $c = getBar (); (Incorrect)Function Return Type Hint:
- Add a space after the colon in the function return type hint.
Example: function square( int $x ): int { return $x * $x; }Arrays:
- Use spaces in brackets when declaring an array, except where the array is empty.
Example: $a = [ 'foo', 'bar' ]; (Correct) $a = ['foo', 'bar']; (Incorrect)- Do not put spaces in brackets when accessing array elements.
Example: $c = $a[0]; (Correct) $c = $a[ 0 ]; (Incorrect)Control Structures:
- Add a space after control structure keywords.
Example: if ( isFoo() ) { ... } (Correct) if(isFoo()){ ... } (Incorrect)Type Casting:
- Do not use a space within or after the cast operator.
Example: (int)$foo; (Correct) (int) $bar; (Incorrect)Comments:
- In comments, there should be one space between the # or // and the comment text.
Example: // This is a comment. (Correct) //This is a comment. (Incorrect)Ternary Operator:
- Keep ternary operator expressions short and obvious.
- For multi-line ternary expressions, place the '?' and ':' at the beginning of the new lines.
File Formatting:
- Avoid trailing whitespace on lines.
Additional comments not posted (2)
extension.json (1)
133-137
: The addition of theHtmlPageLinkRendererEnd
andBeforePageDisplay
hooks aligns with the PR's objective to improve SEO. Ensure that these hooks are correctly implemented and tested.Verification successful
The implementations for the
onHtmlPageLinkRendererEnd
andonBeforePageDisplay
functions have been successfully extracted and reviewed. Both functions appear to be correctly handling their respective hooks to improve SEO by addingnofollow
attributes and settingnoindex
policies for certain pages.
onHtmlPageLinkRendererEnd
: Adds anofollow
attribute to links that are not known or are external.onBeforePageDisplay
: Sets anoindex,nofollow
policy for specific namespaces and based on certain URL parameters.These implementations align with the intended functionality to improve SEO.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of new hooks in the PHP files. # Test: Search for the implementation of the new hooks. Expect: Proper implementation and usage. rg --type php --files-with-matches $'public function onHtmlPageLinkRendererEnd|public function onBeforePageDisplay' ./includesLength of output: 148
Script:
#!/bin/bash # Description: Extract the implementation of the new hooks in the PHP files. # Extract the implementation of the onHtmlPageLinkRendererEnd function. ast-grep --lang php --pattern $'function onHtmlPageLinkRendererEnd($_) { $$$ }' ./includes/Hooks.php # Extract the implementation of the onBeforePageDisplay function. ast-grep --lang php --pattern $'function onBeforePageDisplay($_) { $$$ }' ./includes/Hooks.phpLength of output: 415
Script:
#!/bin/bash # Description: Extract the implementation of the new hooks in the PHP files using rg. # Extract the implementation of the onHtmlPageLinkRendererEnd function. rg --type php -A 20 'function onHtmlPageLinkRendererEnd' ./includes/Hooks.php # Extract the implementation of the onBeforePageDisplay function. rg --type php -A 20 'function onBeforePageDisplay' ./includes/Hooks.phpLength of output: 1231
includes/Hooks.php (1)
30-31
: The addition ofBeforePageDisplayHook
andHtmlPageLinkRendererEndHook
declarations is appropriate for the SEO improvements. Ensure that these hooks are correctly implemented in their respective methods.Verification successful
The hooks
onHtmlPageLinkRendererEnd
andonBeforePageDisplay
are correctly implemented inincludes/Hooks.php
. The methods contain logic to addnofollow
attributes to links and setnoindex,nofollow
robot policies for certain pages, aligning with the SEO improvements.
onHtmlPageLinkRendererEnd
: Addsrel="nofollow"
to links that are not known or external.onBeforePageDisplay
: Setsnoindex,nofollow
for specific namespaces and blacklisted URL parameters.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of new hooks in the PHP files. # Test: Search for the implementation of the new hooks. Expect: Proper implementation and usage. rg --type php --files-with-matches $'public function onHtmlPageLinkRendererEnd|public function onBeforePageDisplay' ./includesLength of output: 148
Script:
#!/bin/bash # Extract the implementation of the hooks from includes/Hooks.php # Extract the method onHtmlPageLinkRendererEnd ast-grep --lang php --pattern $'public function onHtmlPageLinkRendererEnd($_, $_, $_) { $$$ }' includes/Hooks.php # Extract the method onBeforePageDisplay ast-grep --lang php --pattern $'public function onBeforePageDisplay($_) { $$$ }' includes/Hooks.phpLength of output: 433
Script:
#!/bin/bash # Extract the implementation of the hooks from includes/Hooks.php using rg # Search for the method onHtmlPageLinkRendererEnd rg --type php 'public function onHtmlPageLinkRendererEnd' includes/Hooks.php -A 20 # Search for the method onBeforePageDisplay rg --type php 'public function onBeforePageDisplay' includes/Hooks.php -A 20Length of output: 1241
Oops, something went wrong! Please try again later. 🐰 💔 |
Tip For best results, initiate chat on the files or code changes. @colleirose, I apologize for the confusion earlier. Upon reviewing the changes in the Thank you for pointing out the discrepancy. If you have any further questions or need additional assistance, please let me know! Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check the diff of the includes/Hooks.php file in the PR to verify the changes.
git diff origin/main...HEAD -- includes/Hooks.php
Length of output: 92 Script: #!/bin/bash
# Fetch the correct branch names
MAIN_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
PR_BRANCH=$(git branch --show-current)
# Check the diff of the includes/Hooks.php file in the PR to verify the changes.
git diff $MAIN_BRANCH...$PR_BRANCH -- includes/Hooks.php
Length of output: 5246 New Learnings Added
|
@Universal-Omega Done, can you check again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Out of diff range and nitpick comments (1)
includes/Hooks.php (1)
Line range hint
17-27
: Ensure proper spacing around operators and within array declarations as per MediaWiki PHP coding standards.- use MediaWiki\Hook\BeforePageDisplayHook; - use MediaWiki\Hook\BlockIpCompleteHook; - use MediaWiki\Hook\ContributionsToolLinksHook; - use MediaWiki\Hook\GetLocalURL__InternalHook; - use MediaWiki\Hook\MimeMagicInitHook; - use MediaWiki\Hook\RecentChange_saveHook; - use MediaWiki\Hook\SiteNoticeAfterHook; - use MediaWiki\Hook\SkinAddFooterLinksHook; + use MediaWiki\Hook\BeforePageDisplayHook; + use MediaWiki\Hook\BlockIpCompleteHook; + use MediaWiki\Hook\ContributionsToolLinksHook; + use MediaWiki\Hook\GetLocalURL__InternalHook; + use MediaWiki\Hook\MimeMagicInitHook; + use MediaWiki\Hook\RecentChange_saveHook; + use MediaWiki\Hook\SiteNoticeAfterHook; + use MediaWiki\Hook\SkinAddFooterLinksHook;
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- extension.json (2 hunks)
- includes/Hooks.php (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- extension.json
Additional Context Used
Path-based Instructions (1)
includes/Hooks.php (1)
Pattern
**/*.php
: Follow MediaWiki PHP Coding Standards:Indentation:
- Use tabs for indentation, not spaces.
Spaces:
- Use spaces on either side of binary operators.
Example: $a = $b + $c; (Correct) $a=$b+$c; (Incorrect)- Add spaces inside parentheses, except where they are empty.
Example: $a = getFoo( $b ); (Correct) $a = getFoo($b); (Incorrect)- Do not add a space after a function name.
Example: $c = getBar(); (Correct) $c = getBar (); (Incorrect)Function Return Type Hint:
- Add a space after the colon in the function return type hint.
Example: function square( int $x ): int { return $x * $x; }Arrays:
- Use spaces in brackets when declaring an array, except where the array is empty.
Example: $a = [ 'foo', 'bar' ]; (Correct) $a = ['foo', 'bar']; (Incorrect)- Do not put spaces in brackets when accessing array elements.
Example: $c = $a[0]; (Correct) $c = $a[ 0 ]; (Incorrect)Control Structures:
- Add a space after control structure keywords.
Example: if ( isFoo() ) { ... } (Correct) if(isFoo()){ ... } (Incorrect)Type Casting:
- Do not use a space within or after the cast operator.
Example: (int)$foo; (Correct) (int) $bar; (Incorrect)Comments:
- In comments, there should be one space between the # or // and the comment text.
Example: // This is a comment. (Correct) //This is a comment. (Incorrect)Ternary Operator:
- Keep ternary operator expressions short and obvious.
- For multi-line ternary expressions, place the '?' and ':' at the beginning of the new lines.
File Formatting:
- Avoid trailing whitespace on lines.
Additional comments not posted (1)
includes/Hooks.php (1)
Line range hint
63-73
: Added interfaces are aligned with the PR's objective to handle new hooks. Ensure that these interfaces are implemented correctly in the methods below.
Looks weird in GitHub diffs but not on my machine for some reason (this is why I prefer spaces over tabs, tab sizes...)
… review bot suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- includes/Hooks.php (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- includes/Hooks.php
No idea why I didn't realize this, the extension was actually running fine on my local install, very odd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks a lot better. Still a few things though. Sorry if I am a bit particular here, I just like clean formatting meeting most standards. For the most part this PR looks pretty good though.
Missed in last commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- includes/Hooks.php (5 hunks)
Files skipped from review as they are similar to previous changes (1)
- includes/Hooks.php
@pixDeVl Please make a PR to set up ManageWiki so that by default (i.e. user can change it) these namespaces and all talk pages (regardless of whether they relate to the namespaces listed here) default to noindex nofollow: User Thanks |
Actions performedReview triggered.
|
Ideally, this will be done in ManageWiki later, as has been described previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- includes/Hooks.php (5 hunks)
Additional context used
Path-based instructions (1)
includes/Hooks.php (1)
Pattern
**/*.php
: Follow MediaWiki PHP Coding Standards:Indentation:
- Use tabs for indentation, not spaces.
Spaces:
- Use spaces on either side of binary operators.
Example: $a = $b + $c; (Correct) $a=$b+$c; (Incorrect)- Add spaces inside parentheses, except where they are empty.
Example: $a = getFoo( $b ); (Correct) $a = getFoo($b); (Incorrect)- Do not add a space after a function name.
Example: $c = getBar(); (Correct) $c = getBar (); (Incorrect)Function Return Type Hint:
- Add a space after the colon in the function return type hint.
Example: function square( int $x ): int { return $x * $x; }Arrays:
- Use spaces in brackets when declaring an array, except where the array is empty.
Example: $a = [ 'foo', 'bar' ]; (Correct) $a = ['foo', 'bar']; (Incorrect)- Do not put spaces in brackets when accessing array elements.
Example: $c = $a[0]; (Correct) $c = $a[ 0 ]; (Incorrect)Control Structures:
- Add a space after control structure keywords.
Example: if ( isFoo() ) { ... } (Correct) if(isFoo()){ ... } (Incorrect)Type Casting:
- Do not use a space within or after the cast operator.
Example: (int)$foo; (Correct) (int) $bar; (Incorrect)Comments:
- In comments, there should be one space between the # or // and the comment text.
Example: // This is a comment. (Correct) //This is a comment. (Incorrect)Ternary Operator:
- Keep ternary operator expressions short and obvious.
- For multi-line ternary expressions, place the '?' and ':' at the beginning of the new lines.
File Formatting:
- Avoid trailing whitespace on lines.
Additional comments not posted (1)
includes/Hooks.php (1)
Line range hint
17-27
: Verify the correct implementation of newly added interfaces and hooks.The class
Hooks
now implements several new interfaces, includingBeforePageDisplayHook
andHtmlPageLinkRendererEndHook
. Ensure that these interfaces are correctly used in the methodsonHtmlPageLinkRendererEnd
andonBeforePagePageDisplay
, and that all necessary conditions are met for these hooks to function as expected.Also applies to: 63-73
Tip For best results, initiate chat on the files or code changes. @colleirose, I appreciate your patience and your humor! 🐰 While I strive for perfection, sometimes things don't go as planned. If there's anything specific you need help with right now, please let me know, and I'll do my best to assist. Let's make the future a bit brighter together! |
Looks okay, just needs testing now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs more testing because when I tested and profiled last it seemd to have about a 100-200ms impact on performance which is a pretty significant impact. Now that we improved performance elsewhere we should see if that still happens.
Out of curiosity, what's preventing the nofollow on redlinks from being implemented in MediaWiki core? (Though I suppose doing it through Miraheze may be faster, so :p) |
I don't know where to make upstream PRs. I also don't think they make SEO a priority upstream. |
* This method modifies the 'rel' attribute of links to include 'nofollow' when the target page does not exist. This is to prevent search engines from trying to index non-existent or low-value pages. This is important for SEO as it helps to optimize the crawl budget by not wasting it on pages that do not contribute to the site's content | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to the spacing here? And why is the text not hardwrapped like below?
Google has indexed some really useless pages on miraheze.org, hopefully this can help reduce that.