由于某种原因<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代码。对我来说,我已经清楚地表明,我要在head标签中指定title和meta标签。上面的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;
}
|]
我不知道问题是什么。
如果你只是从落HTMLwhamlet
直接defaultLayout
,它会在toWidget
等的<body>
。特别是标题,请使用setTitle
进行设置。对于剩余的其他内容<head>
(例如你的meta标签),请将其hamlet
准引号包裹在中toWidgetHead
。