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

Refactor RobotsTxt.php to correctly generate the Sitemap URLs by appending a forward slash before each sitemap path. #14

Merged
merged 4 commits into from
Dec 8, 2024

Conversation

thejmitchener
Copy link
Member

@thejmitchener thejmitchener commented Dec 8, 2024

Pull Request Description

This pull request refactors the RobotsTxt.php file to ensure that the generated Sitemap URLs are correctly formatted by appending a forward slash before each sitemap path.

Motivation

The current implementation does not consistently include a leading slash in the Sitemap URLs, which can lead to malformed URLs in the robots.txt file. This inconsistency can negatively impact search engine crawling and indexing, potentially reducing the visibility of the site's content.

Changes Made

  • Updated the generate() method in RobotsTxt.php to use rtrim() on the application URL to remove any trailing slashes.
  • Ensured that each sitemap path is preceded by a forward slash when constructing the Sitemap URLs.
  • Adjusted the corresponding tests to verify that the Sitemap URLs are correctly formatted.

Benefits

By making these changes, we improve the reliability of the Sitemap URLs generated in the robots.txt file. This refinement enhances our SEO efforts and ensures that search engines can correctly access and index all site content, ultimately contributing to better site performance in search results.

@thejmitchener thejmitchener reopened this Dec 8, 2024
@thejmitchener thejmitchener enabled auto-merge (squash) December 8, 2024 19:07
…tsTxtEnvironmentTest.php and RobotsTxtSitemapTest.php to ensure correct URL formatting.
…re made to ensure that the job runs only if the actor is not Dependabot.
@thejmitchener thejmitchener merged commit dc45df2 into main Dec 8, 2024
7 checks passed
@thejmitchener thejmitchener deleted the url-rtrim branch December 8, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant