HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleyesod-core-1.6.26.0Haskell2010

Yesod.Core.Widget

Widgets combine HTML with JS and CSS dependencies with a unique identifier generator, allowing you to create truly modular HTML components.

  • 4 types
  • 4 classes
  • 25 values

Datatype

3 declarations
newtypenewtype WidgetFor site a
#

A generic widget, allowing specification of both the subsite and master site datatypes. While this is simply a WriterT, we define a newtype for better error messages.

Instances20ToWidget, Monad, Functor, Applicative, MonadIO, MonadThrow, …

Special Hamlet quasiquoter/TH for Widgets

4 declarations

Convert to Widget

4 declarations
classclass ToWidget site a where
#

Methods

Instances12ToWidget, …
  • ToWidget site HtmlDefined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • ToWidget site CssDefined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • ToWidget site JavascriptDefined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • ToWidget site TextDefined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • ToWidget site BuilderDefined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • ToWidget site TextDefined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • ToWidget site CssBuilderDefined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • (site' ~ site, a ~ ()) => ToWidget site' (WidgetFor site a)Defined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • render ~ RY site => ToWidget site (render -> Html)Defined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • render ~ RY site => ToWidget site (render -> Css)Defined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • render ~ RY site => ToWidget site (render -> Javascript)Defined in yesod-core-1.6.26.0 · Yesod.Core.Widget
  • render ~ RY site => ToWidget site (render -> CssBuilder)Defined in yesod-core-1.6.26.0 · Yesod.Core.Widget
classclass ToWidgetHead site a where
#

Methods

Instances8ToWidgetHead, …
classclass ToWidgetBody site a where
#

Methods

Instances4ToWidgetBody
classclass ToWidgetMedia site a where
#

Allows adding some CSS to the page with a specific media type.

Since 1.2

Methods

Instances4ToWidgetMedia

Creating

0 declarations

Head of page

valuesetTitle :: MonadWidget m => Html -> m ()
#

Set the page title.

Calling setTitle or setTitleI multiple times overrides previously set values.

SEO Notes:

  • Title tags are the second most important on-page factor for SEO, after content

  • Every page should have a unique title tag

  • Start your title tag with your main targeted keyword

  • Don't stuff your keywords

  • Google typically shows 55-64 characters, so aim to keep your title length under 60 characters

valuesetDescription :: MonadWidget m => Text -> m ()
#

setDescription is not idempotent; we recommend setDescriptionIdemp instead Multiple calls to setDescription will insert multiple meta tags in the page head. If you want an idempotent function, use setDescriptionIdemp - but if you do, you may need to change your layout to include pageDescription.

Add description meta tag to the head of the page

Google does not use the description tag as a ranking signal, but the contents of this tag will likely affect your click-through rate since it shows up in search results.

The average length of the description shown in Google's search results is about 160 characters on desktop, and about 130 characters on mobile, at time of writing.

Source: https://www.advancedwebranking.com/blog/meta-tags-important-in-seo/

valuesetDescriptionI
  1. :: (MonadWidget m, RenderMessage (HandlerSite m) msg)
  2. => msg
  3. -> m ()
#

setDescriptionI is not idempotent; we recommend setDescriptionIdempI instead Multiple calls to setDescriptionI will insert multiple meta tags in the page head. If you want an idempotent function, use setDescriptionIdempI - but if you do, you may need to change your layout to include pageDescription.

Add translated description meta tag to the head of the page

n.b. See comments for setDescription.

valuesetDescriptionIdemp :: MonadWidget m => Text -> m ()
#

Add description meta tag to the head of the page

Google does not use the description tag as a ranking signal, but the contents of this tag will likely affect your click-through rate since it shows up in search results.

The average length of the description shown in Google's search results is about 160 characters on desktop, and about 130 characters on mobile, at time of writing.

Unlike setDescription, this version is *idempotent* - calling it multiple times will result in only a single description meta tag in the head.

Source: https://www.advancedwebranking.com/blog/meta-tags-important-in-seo/

valuesetOGImage :: MonadWidget m => Text -> m ()
#

Add OpenGraph image meta tag to the head of the page

Best practices:

  • Use custom images for shareable pages, e.g., homepage, articles, etc.

  • Use your logo or any other branded image for the rest of your pages.

  • Use images with a 1.91:1 ratio and minimum recommended dimensions of 1200x630 for optimal clarity across all devices.

Source: https://ahrefs.com/blog/open-graph-meta-tags/

CSS

newtypenewtype CssBuilder
#

Newtype wrapper allowing injection of arbitrary content into CSS.

Usage:

toWidget $ CssBuilder "p { color: red }"

Since: 1.1.3

Instances6ToWidget, ToWidgetHead, ToWidgetMedia

Javascript

Subsites

1 declaration

Internal

2 declarations