我想知道如何在登錄頁面上顯示替代“標題”和其他元數據。假設我有一個目標 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 關注
- 103 瀏覽
添加回答
舉報
0/150
提交
取消