Skip sitemap generation when there is no valid base URL #1660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before, this would fall back to a relative URL, but these no longer validate by Google and will not be indexed. It feels a bit dramatic to have an exception be thrown when building test sites locally so instead we just skip the build, but with a helpful message.
Technically this can be seen as a breaking change, as this results in a sitemap file not being generated. But the end result in both cases is the same. Before this change we in this scenario when missing a base URL we get a sitemap that cannot be indexed, and after this change we don't generate a sitemap at all. In both cases, Google will not index the site using the sitemap. In the new case, we at least provide a notice to the user. I think this better follows the principle of least astonishment and thus I believe this justifies targeting HydePHP v1.6 instead of v2.0.
The reason we consider localhost to be a non-valid URL is a tradeoff between users wanting to see what the sitemap looks locally, and when building for production in a CI where they forgot to configure an environment variable. I think the latter weights more heavily here. We could also add a
--force
flag to thebuild:sitemap
command, but I don't think the complexity is warranted.