Add "Main URL" to "Basic site settings" and "Status Report" page.

Created on 11 May 2024, 9 months ago
Updated 20 June 2024, 8 months ago

SEE DIFF HERE: https://git.drupalcode.org/issue/drupal-3446674/-/compare/11.x...3446674...

Problem/Motivation

A Drupal site does not tell the user anything about what domain name it is running under, or what domain will be the live one.

If you don't see the browser's URL, it is actually impossible to tell the difference between a live site and a copy unless the developers added Environment Indicator module or some other solution.

This idea originated in Site.module, and is a part of the effort to add a Site entity to core. See parent issue.

Steps to reproduce

  1. Load /admin/reports/status.
  2. Load /admin/reports/status on a cloned environment with the same server config.
  3. Note there is zero difference between these pages.
  4. Load any Drupal websites status page, and without looking at the browser URL, try to figure out what site you are looking at.

Proposed resolution

  1. Add "Canonical URL" to the Basic site information form.
  2. Display the "Canonical URL" on the "Status Report" page.
  3. If the current host is not the canonical URL, show an indicator in the admin toolbar.

I'm trying to improve UX/OX on the status report, so in addition I added site name in this MR.

Remaining tasks

  1. Add some kind of indicator if a site is NOT the canonical site.
  2. Figure out how to handle aliases of the canonical URL. If the site is running under multiple domains, we don't want to display an indicator saying the site is NOT canonical.
    • Option 1: Make the field "canonical_urls" a textarea with one per line.
    • Option 2: Add an additional "canonical _url_aliases" textarea.

User interface changes

Adds "Canonical URL" to basic site settings form.

Adds Site Name, "Main URL" and "Current URL" to Status Report page.

API changes

None.

Data model changes

Adds canonical_url to system.site config.

Release notes snippet

TBD

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
SystemΒ  β†’

Last updated 7 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

Live updates comments and jobs are added and updated live.
  • Needs product manager review

    It is used to alert the product manager core committer(s) that an issue represents a significant new feature, UI change, or change to the "user experience" of Drupal, and their signoff is needed. If an issue significantly affects the usability of Drupal, use Needs usability review instead (see the governance policy draft for more information).

Sign in to follow issues

Comments & Activities

  • Issue created by @Jon Pugh
  • Status changed to Needs review 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    Seems reasonable. Canonical feels too developer

    Laravel has this as well, `url`. It's used for CLI URL generation.

    'url' => env('APP_URL', 'http://localhost'),
    

    I'm sure other projects also have this. Would be nice for Drush when using the default site.

  • πŸ‡§πŸ‡·Brazil ferox JoΓ£o Pessoa

    Up!

    Wil be an awesome feature.

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    @matt: is the APP_URL for the current site? Or as a reference for the live site?

    This is to store the live site so users can see it in status reports etc.

    I think the screenshot is confusing. The default value is whatever site you are on, hence "localhost" because I was using PHP CLI server, but normally you would put in a separate domain.

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    @matt: is the APP_URL for the current site? Or as a reference for the live site?

    It's the current site. So example.com or uat.example.com.

    You're meaning it should always be the production URL?

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY
  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    Matt: I'm thinking Main URL is a good human label, but like canonical for the property name.

    Open to whatever.

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    Like

    SiteService::isCanonical() as a universal way to see if a site is "live" or not.

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    Update: After thinking a few days I think "Main URL" is the best human-readable name for this property.

    "Canonical URL" is still good for the backend, I think. "Main URL" is a little vague when used in code.

    Thoughts?

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    Development on this feature has moved to ✨ Add "system.site" service to access information about the site. Active . Keeping this issue for discussing the Main URL field specifically.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Talking to a committer and this needs product manager sign off.

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    Matt: Yes, this is specifically for the prod URL. Can be used both for showing admin users in the status report page, and for detecting if a site is "live" or not.

  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    Okay, so it is not the current site's URL but intended to reflect whatever is the live/production URL for the codebase.

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    I coincidentally installed metatags on my site yesterday, and it has a field "Canonical URL".

    Did a little digging. Seems like this could be useful for printing these tags.

    https://developers.google.com/search/docs/crawling-indexing/canonicaliza...

  • πŸ‡ΊπŸ‡ΈUnited States Jon Pugh Newburgh, NY

    @mglaman yep. I thought "Basic site info" would be a good place for it because email is there too. It feels like that form is the core identity of the site.

    Also, if Drupal core had this feature, it could set DRUPAL_ENV to prod only if the URL matches. It would be a very simple way to detect environment on any system. No more if/then/else clutter in settings.php.

    A comment by Ryan Price on linkedin brought up "trusted hosts"... Maybe we need a "trusted prod hosts"?

  • πŸ‡ΊπŸ‡ΈUnited States liberatr Portland, OR

    If you want the site to report "this is my canonical public URL", it should be validated against trusted host patterns.

  • Status changed to Needs work 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States xjm

    I think this issue might be a wontfix:

    • Having a new required field on every single Drupal site, especially one that does not affect the production user experience, seems like it is fixing an edgecase at the expense of the evaluator and site owner experience for all sites.
    • Adding additional form elements always inevitably causes a usability regression, so we should make sure the usability benefit of adding the element outweighs that regression.
    • It is also relevant for the product manager role because it affects the evaluator experience of Drupal. Adding an additional thing that must be configured (at site install maybe even?) is a non-trivial increase in the amount of configuration necessary to get up and running.

    At a minimum, I think the field should be optional rather than required, and have a sensible default value if the user doesn't provide one. Furthermore, though, this could be addressed with a contrib module and might not even be appropriate for core.

    If folks do still feel this belongs in core, then at a minimum, the field should be made optional. Then, that could be submitted for usability review (tagged "Needs usability review") once that change is made. Furthermore, even if the usability team gives the addition a +1 (benefit outweighing negative UX impact), this would still require product manager signoff because it affects the evaluator experience of Drupal.

    Also, there is not actually a merge request here ATM, so we would need that too before proceed.

    My personal recommendation is actually to mark this wontfix and support it via contrib, but it's outside the scope of my role as a release manager to make a final decision on that myself.

Production build 0.71.5 2024