我想知道如何在登录页面上显示替代“标题”和其他元数据。假设我有一个目标 URL,例如https://example.com/thing/12345 ...如果未登录,用户将被重定向到登录页面,这就是我想要的,但在登录页面上我想从目标页面注入标题,也许还有其他元数据。因此,如果在 Facebook 中共享上述链接,它将显示目标 URL 的标题/元数据,而不是登录 URL。
1 回答

慕无忌1623718
TA贡献1744条经验 获得超4个赞
根据 Laravel 文档:
在您的主模板中使用@yield('title')动态更改标题
<html>
<head>
<title>App Name - @yield('title')</title> // add this code
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
</html>
从您的刀片模板中使用@section('title')将标题传递给主布局
@extends('layouts.master')
@section('title', 'Page Title') // pass dynamic title from here
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@stop
@section('content')
<p>This is my body content.</p>
@stop
- 1 回答
- 0 关注
- 112 浏览
添加回答
举报
0/150
提交
取消