Hamlet html неправильно регистрирует теги ‹head› или ‹title› для моего обработчика домашнего маршрута

По какой-то причине тег <head> для домашней страницы моего веб-сайта не обрабатывается так, как мне хотелось бы. Вот исходный код моего сайта, который я получаю от firefox. Обратите внимание, что первые теги head и title пусты:

<html><head><title></title><style>form{margin:0 auto;width:250px}</style></head><body><head><title>Fishing Weather Hub </title>
<meta name="description" content="Completely free fishing weather data provided by NOAA and Open Weather Maps. Designed to be simple and easy to use.">
<meta name="keywords" content="fishing weather,fishing,weather">
<meta name="robots" content="index,follow">
</head>
<header><center style="font-size:30px">Fishing Weather Hub</center>
...

Вот код на Haskell для этого обработчика маршрута. Для себя я ясно дал понять, что в теге заголовка я хотел бы указать заголовок и метатеги. Вышеприведенный HTML-код не соответствует этому коду.

getHomeR :: Handler Html    
getHomeR = do

  clearSession

  key <- liftIO $ MYP.randomString 9

  setSession "cache_key" (T.pack key) 

  sess <- getSession

  -- Generate the location form
  (widget, enctype) <- generateFormPost $ renderDivs locationForm

  defaultLayout $ do
    [whamlet|
<head>
  <title>Fishing Weather Hub 
  <meta name="description" content="Completely free fishing weather data provided by NOAA and Open Weather Maps. Designed to be simple and easy to use.">
  <meta name="keywords" content="fishing weather,fishing,weather">
  <meta name="robots" content="index,follow">
<header>
  <center style="font-size:30px">Fishing Weather Hub
  <br>
  <form method=post action=@{ProcessLocationFormR} enctype=#{enctype}>
    ^{widget}
    <button>Submit
  <a href="https://www.anglerwise.com/2010/02/09/how-does-barometric-pressure-affect-fishing/">How does barometric pressure affect fishing?
|]
    --CSS
    toWidget
      [lucius|
form {
margin: 0 auto;
width:250px;
}
|]

Я не знаю в чем проблема.


person Nicholas Hubbard    schedule 29.11.2020    source источник


Ответы (1)


Если вы просто перетащите HTML из whamlet прямо в defaultLayout, он попадет в toWidget и так далее в <body>. В частности, для заголовка используйте setTitle, чтобы установить его. Для всего остального, что входит в <head> (например, ваши метатеги), оберните их квази-кавычки hamlet в toWidgetHead.

person Joseph Sible-Reinstate Monica    schedule 29.11.2020