-
Notifications
You must be signed in to change notification settings - Fork 302
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
Added hostname to og:url to include top level domain #7563
Conversation
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.
LGTM
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.
@nick-mon1 I tested locally and in preview. Inner pages don't seem to generate the correct link.
I noticed the baseURL is /
in
Line 2 in 0fd0019
baseURL: "/" |
Changing it to https://digital.gov/
makes permalinks work as expected and follows the guidance here - Configure Hugo | Hugo.
We should investigate why we need the /
and if this is a legacy config option. Alternatively, we could try a workaround like making the permalink absolute.
Example
<meta
property="og:url"
+ content="{{- .Permalink | absURL -}}"
/>
<meta property="og:url" content="{{- .Permalink -}}" /> | ||
<meta | ||
property="og:url" | ||
content="{{ .Site.Params.hostName }}{{- .Permalink -}}" |
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.
Communities
Returns og:url
value of https://digital.gov//localhost:1313/communities/
.
In Cloud Pages preview I see a link that leads to 404:
https://federalist-466b7d92-5da1-4208-974f-d61fd4348571.sites.pages.cloud.gov/preview/gsa/digitalgov.gov/nl-fix-og-url/communities/
It should be:
https://federalist-466b7d92-5da1-4208-974f-d61fd4348571.sites.pages.cloud.gov/preview/gsa/digitalgov.gov/nl-fix-og-url/communities/
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.
@mejiaj Both of the URL's are the same in the examples above. For some reason I do not see https://www.digital.gov
set on my local, still uses localhost:1313
, could be a caching issue with your code suggestions.
- Updated
baseURL: https://www.digital.gov
inconfig.yml
- And set:
<meta property="og:url" content="{{- .Permalink | absURL -}}"/>
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.
URL not displaying as expected.
Previous code change worked as expected.
Explanation
Next Steps@RileySeaburg the current URL's we are seeing are due to cloud.pages configuration, but they should resolve when we merge to main. If not, we should do step 3 above in a follow up PR if this fix doesn't work. |
I think we'll need to reconfigure cloud.gov because otherwise, I'm not sure why it would show the URL like that. |
@nick-mon1 @RileySeaburg Cloud pages has some default environment variables. Could we use that to target the preview builds? |
@mejiaj Yes, we can. @nick-mon1 not sure if you want to just do that or create a task and make this dependent on that task. |
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 good and I don't see the notice bar banner locally anymore.
Summary
Adds top level host name to
og:url
meta tags. Closes #7168.Preview
Link to Preview
Solution
When viewing the
og:url
value on the live site, only the file pathname (/communities/
) is displayed instead ofhttps://www.digital.gov/communities/
.By setting a
hostName
params in theconfig.yml
we can set the base host name.Note
og:url
path will be different for each environmentproduction
{{ .Permalink }}
will only return the file path and not the host name:https://digital.gov/resources/an-introduction-to-domain-management
cloud pages preview
{{ .Permalink }}
returns the preview path and branch name with the file path:https://digital.gov/preview/gsa/digitalgov.gov/nl-fix-og-url/resources/an-introduction-to-domain-management
localhost
{{ .Permalink }}
will return localhost:1313 with the file path:https://digital.gov/localhost:1313/resources/an-introduction-to-domain-management
How To Test
og:url
https://digital.gov/preview/gsa/digitalgov.gov/nl-fix-og-url/resources/an-introduction-to-domain-management
https://digital.gov/resources/an-introduction-to-domain-management
Dev Checklist