如何为多个网站保留相同的标题

时间:2017-10-23 10:55:10

标签: javascript php html

我发现自己陷入了一种非常令人沮丧的境地。我目前正在一个个人网站上工作,每次我对标题感到满意,并且刚刚在所有页面中更新了它;我通常意识到我犯了一个错字或其他问题。这迫使我解决问题,并再次在所有文件中更新它。

所以我的问题是,是否有一些智能PHP或Javascript技巧可以在动态文件中加载并在页面上显示它们?

<小时/> 如果您未充分发现我的问题,请参阅以下内容

基本上,如果我有一个如下所示的标题

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  </head>
  <body>
<div class="container desktop-view">
  <div class="row">
    <div class="col-md-6">
      <div class="row">
        <div class="col-md-6 red"><h1>1</h1></div>
        <div class="col-md-6 red"><h1>1</h1></div>
        <!--if I put the blue boxes here, then I'm not able to have Red2 just below Red1 in mobile layout-->
        <div class="col-md-12 blue"><br><br><br><br><br><br><br><h1>3</h1><br><br><br><br><br><br><br></div>
        <div class="col-md-4 blue"><h1>4</h1></div>
        <div class="col-md-8 blue"><h1>4</h1></div>
      </div>
    </div>
    <div class="col-md-6">
      <div class="row">
        <div class="col-md-12 red">
          <br><br><br><br><br><h1>2</h1><br><br><br><br><br>
        </div>
        <div class="col-md-6 yellow"><h1>5</h1></div>
        <div class="col-md-6 yellow"><h1>5</h1></div>
        <div class="col-md-12 yellow">
          <br><br><h1>6</h1><br><br>
        </div>
      </div>
    </div></div>
    <div class="row">
      <div class="col-md-12 yellow">
        <br><br><h1>7</h1><br><br>
      </div>
    </div>
  </div>
  <div class="container mobile-view">
    <div class="row">
      <div class=" col-md-6 col-sm-6  red"><h1>1</h1></div>
      <div class=" col-md-6 col-sm-6  red"><h1>1</h1></div>
      <div class="col-md-12 red"><br><br><br><br><h1>2</h1><br><br><br><br></div>
      <!--if I put the blue boxes here, then I'm not able to have Red2 just below Red1 in mobile layout-->
      <div class="col-md-12 blue"><br><br><br><br><h1>3</h1><br><br><br><br></div>
      <div class="col-md-4 col-sm-4 col-xs-4 blue"><h1>4</h1></div>
      <div class="col-md-8 col-sm-8 col-xs-8 blue"><h1>4</h1></div>
      <div class="col-md-6 yellow"><h1>5</h1></div>
      <div class="col-md-6 yellow"><h1>5</h1></div>
      <div class="col-md-12 col-sm-12 yellow"><h1>6</h1></div>
      <div class="col-md-12 yellow">
        <br><br><h1>7</h1><br><br>
      </div>
    </div>
  </div>
  </body>
</html>

,是否可以将该标头存储在一个单独的文件中并为每个页面动态加载?

1 个答案:

答案 0 :(得分:2)

你使用PHP吗?然后你可以用PHP包括:

<head>

</head>

<body>

<?php include("includes/header.html");?>

</body>
</html>