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

Hugo: add the meta description tag to the head of the html #377

Conversation

ErikHendrikson
Copy link

This will add the meta tag with name="description" to the head of the html.

  • the value of the tag will be set to the page's params description;

  • with a fallback to the, by Hugo generated, summary of the page; and

  • with a fallback to the general description of the Site Params;

For https://linear.app/usmedia/issue/CUE-252

@netlify
Copy link

netlify bot commented Jul 20, 2023

Deploy Preview for cue ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit dee8d63
🔍 Latest deploy log https://app.netlify.com/sites/cue/deploys/64be87707f9585000861e137
😎 Deploy Preview https://deploy-preview-377--cue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ErikHendrikson ErikHendrikson marked this pull request as ready for review July 20, 2023 14:33
@anne-usmedia anne-usmedia requested a review from myitcv July 20, 2023 14:34
@myitcv
Copy link
Member

myitcv commented Jul 21, 2023

Thanks @ErikHendrikson - what happens in the case that a description is multi-line? Do things still work ok and generate valid HTML?

@ErikHendrikson ErikHendrikson marked this pull request as draft July 21, 2023 13:12
@JorindeUsMedia JorindeUsMedia self-requested a review July 24, 2023 07:42
@JorindeUsMedia
Copy link
Collaborator

Thanks @ErikHendrikson - what happens in the case that a description is multi-line? Do things still work ok and generate valid HTML?

Is you use the description in the front-matter this should not contain empty lines and should not contain html tags etc. The fallback for hugo is Summary. See https://gohugo.io/content-management/summaries/ how hugo handles this.
Note: Erik solution is the same as Hugo internals already uses for the open graph description tag.

@JorindeUsMedia
Copy link
Collaborator

Thanks @ErikHendrikson - what happens in the case that a description is multi-line? Do things still work ok and generate valid HTML?

Is you use the description in the front-matter this should not contain empty lines and should not contain html tags etc. The fallback for hugo is Summary. See https://gohugo.io/content-management/summaries/ how hugo handles this. Note: Erik solution is the same as Hugo internals already uses for the open graph description tag.

Just noticed there is an open PR concerning empty lines etc in Summary.
Maybe we can use the solution proposed in the pr for meta-description. For the internal (opengraph, twitter etc) we have to either wait for hugo to merge this pr or handle them ourselves (not preferred) @ErikHendrikson

gohugoio/hugo#9818
gohugoio/hugo#9856

Copy link
Collaborator

@JorindeUsMedia JorindeUsMedia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on pr. Maybe we can try to make this more solid.

@ErikHendrikson ErikHendrikson force-pushed the feature/cue-251-add-meta-description branch 3 times, most recently from e97a244 to 01a00e8 Compare July 24, 2023 11:47
@ErikHendrikson ErikHendrikson force-pushed the feature/cue-251-add-meta-description branch from 01a00e8 to 59bf391 Compare July 24, 2023 12:10
hugo/layouts/partials/site/head.html Outdated Show resolved Hide resolved
hugo/layouts/partials/site/head.html Outdated Show resolved Hide resolved
This will add the meta tag with name="description" to the head of the html.

- the value of the tag will be set to the page's params description;

- with a fallback to the, by Hugo generated, summary of the page, truncated
to 160 characters for SEO optimalization; and

- with a fallback to the general description of the Site Params;

For https://linear.app/usmedia/issue/CUE-252

Signed-off-by: Erik Hendrikson <erik.hendrikson@usmedia.nl>
@ErikHendrikson ErikHendrikson marked this pull request as ready for review July 24, 2023 15:16
Copy link
Member

@myitcv myitcv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for now. We emit an ellipsis as part of the description which doesn't seem to make much sense... but I suggest we revisit this later as it's not critical now.

@jpluscplusm
Copy link
Collaborator

Imported into Gerrit

cueckoo pushed a commit that referenced this pull request Jul 26, 2023
This will add the meta tag with name="description" to the head of the html.

- the value of the tag will be set to the page's params description;

- with a fallback to the, by Hugo generated, summary of the page, truncated
to 160 characters for SEO optimalization; and

- with a fallback to the general description of the Site Params;

For https://linear.app/usmedia/issue/CUE-252

Closes #377 as merged as of commit dee8d63.

Signed-off-by: Erik Hendrikson <erik.hendrikson@usmedia.nl>
Change-Id: Ia8e184a6729dc025d1f1cb4d5b510f5133596034
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/556912
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>
@jpluscplusm
Copy link
Collaborator

Closed via 0d3a50b

@ErikHendrikson ErikHendrikson deleted the feature/cue-251-add-meta-description branch March 11, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants