Problem/Motivation
It'd be nice if the user could specify the base URL to use for the index.
This is useful if you're running a headless CMS running under a different domain than the public facing one, and would like changes to the entity to trigger an index under a specific domain.
Steps to reproduce
N/A
Proposed resolution
1. Provide a configuration for setting the base URL to use for the index link.
2. Add a special index_now option to the URL so that specific outbound processors (built into the module, or custom) may switch the base URL as necessary.
Remaining tasks
Provide MR.
User interface changes
There might be a new configuration for specifying the optional base URL to use.
API changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | Capture d’écran du 2026-04-26 20-37-04.png | 77.24 KB | macsim |
Issue fork index_now-3586683
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
macsim commentedHi codebymikey
Thank you for opening this issue and for taking the time to provide a merge request - the use case is clear and the overall approach is well thought out.
The idea of using an
OutboundPathProcessorInterfacetagged service is idiomatic Drupal and a clean way to handle this. Marking URLs with anindex_nowoption to scope the processing is also a good pattern that leaves room for custom processors on the site level.A few things to address before we can move forward:
Unused service argument
@index_now.apikey.manageris declared as an argument inindex_now.services.ymlbutIndexNowOutboundPathProcessorhas no constructor and never uses it. Either the argument should be removed from the service definition, or there is a missing constructor - could you clarify the intent?Alias URLs won't be processed
The condition in
processOutboundincludes!empty($options['route']), which excludes unrouted URLs. However,PathAliasOperations::buildAliasUrl()usesUrl::fromUri('base:...'), which goes throughUnroutedUrlAssembler-$options['route']will never be set for those URLs. Theindex_nowoption is correctly set on them in the MR, but the processor will silently skip them.Since
UnroutedUrlAssemblerdoes honour$options['base_url'],removing the
!empty($options['route'])guard should make the override work for both entity and alias URLs. If there is a reason to keep this distinction, it would be good to document it.Minor: no processor priority setNo processor priority neededThepath_processor_outboundtag has nopriorityattribute. This is not blocking, but worth being explicit about in case other processors on the site also manipulatebase_url.The
path_processor_outboundtag intentionally has nopriorityset. This processor only acts on URLs explicitly flagged withindex_now, so ordering relative to other processors is not a concern - no other processor will compete over base_url for these URLs.Once these points are addressed we can move forward with a proper review.
Thanks again for the contribution!
Comment #4
codebymikey commentedGood points! And thanks for addressing some of them for me. I ran into the alias issue as well, and was in the process of creating test coverage for the alias override code, but didn't get round to finishing it off yesterday.
I'll try rebase against your version, then add the remaining test coverage sometime today.
Edit: just saw your final push, I guess that's everything (I don't the think a priority on the path processor is strictly necessary as the default is 0 anyway, and those needing to override it can add a higher priority if they need to)
Comment #5
macsim commentedComment #6
macsim commentedEverything seems to be settled and covered now.
If you have a testing environment, feel free to use it :)
I'll make a second MR for the 4.0.x branch.
Comment #8
macsim commentedThe automated test suite covers the path processor for routed URLs (entity URLs)
and
buildAliasUrl()in isolation. One scenario is not covered byautomated tests: the full end-to-end pipeline from an entity save to the actual
IndexNow API request.
Before merging, it is recommended to manually verify the following:
settings.local.php:https://other-domain.comas the base, not the internal Drupaldomain.
Comment #9
macsim commentedGot an error on the 4.0.x branch while manual testing (and I am pretty sure the same behavior would occur on 3.1.x):
The
keyLocationdomain is not the same as the indexed URL's domain.#3557839: Allow Users to alter URLs submitted to Index Now and Key Location URL could do the trick but it would need a developer to write code.
Alternatively, we can use
$settings['index_now.base_url']to also build thekeyLocationURL when the setting is configured.However, Drupal won't be able to serve the API key file on the other domain - it will need to be created manually there. We will need to document this clearly in
README.md.Comment #10
macsim commentedComment #11
macsim commentedManual testing is ok now
Going to merge on both branches.
Thanks again codebymikey
Comment #14
macsim commentedComment #16
codebymikey commentedThanks for the swift feedback and subsequent implementation Maxime!
I've applied the patch onto the site and will open a follow-up issue if there are any more issues.
Comment #17
macsim commentedYou're welcome.
I also reopened a postponed issue and implemented a hook to handle advanced use cases where URL patterns differ between the Drupal backend and the frontend domain: #3557839: Allow Users to alter URLs submitted to Index Now and Key Location URL
For example, if your Drupal instance serves content at
/node/123or/en/article/my-slugbut your frontend (decoupled, reverse-proxy, CDN, etc.) exposes those pages under a completely different URL structure, a developer can now implementhook_index_now_urls_alter()to rewrite the submitted URLs accordingly - ensuring that what gets sent to IndexNow always reflects the actual public-facing URLs indexed by search engines.