Vuepress - 如何仅在特定页面上的 head 标签中添加自定义 html?

尤修·戈戈伊

我想添加架构标签并将我的自定义 CSS 加载到某些特定页面的head 标签中,而不是全部,那么他们有什么简单的方法可以做到这一点,因为我不是编码员,有人可以帮我解决这个问题吗?

阿布·阿卜杜拉

要添加自定义样式我使用下面的代码在默认安装vuepressindex.styl.vuepress/styles/,以更新content__defaultCSS类:

/**
 * Custom Styles here.
 *
 * ref:https://v1.vuepress.vuejs.org/config/#index-styl
 */

.home .hero img
  max-width 450px!important
.content__default
  background-color  #3df085

屏幕: 在此处输入图片说明

关于 SEO 标签,我建议使用loris 插件


阅读您的评论后,我看到自定义布局是解决方案。

通过config.js以下方式将标签添加到头部

  head: [
    ['meta', { name: 'theme-color', content: '#3eaf7c' }],
    ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
    ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
  
  ['meta', { 'property': 'og:type', 'content': 'article' }]
  ],

使用默认主题轻松定制

  1. 使用自定义页面类为每个页面自定义样式
  2. 使用yaml header为每个页面添加标签

#1 和 #2 的示例:

/博客/README.md

---
pageClass: blog-page
home: true
heroText: Hero Title
actionLink: /blog/
meta:
  - name: description
    content: blog page by abuabdellah
  - name: keywords
    content: super duper SEO
---

# Introduction

This is a test for a blog using v1 Vuepress

/guide/README.md

---
pageClass: guide-page
meta:
  - name: description
    content: guide page by abuabdellah
  - name: keywords
    content: super duper SEO
---

# Introduction

VuePress is composed of two parts

索引样式

.theme-container.blog-page
  background-color blue !important

.theme-container.guide-page
  background-color green !important

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何为Vuepress的特定页面使用自定义布局?

在drupal 9中。如何在 <head></head> 之间添加自定义html做一个钩子或其他东西而不是安装一个模块

仅在一个特定页面上的<head>中添加脚本(反应)

如何添加自定义 HTML 标签 TSX

vuepress-如何使用注册组件自定义组件目录'.vuepress / components'的位置?

如何在ckeditor中定义自定义html标签

在Zend Framework 2中将自定义HTML添加到<head>标记

如何通过 Google 标签管理器在 AMP Container 中添加自定义 HTML 和 Javascript 标签?

如何在Vuepress中添加Firebase?

如何在JSX中添加自定义html属性

如何在 Drupal 中添加自定义 HTML 表单

如何显示自定义html标签?

在vuepress中更改404页面

Vuepress:使侧栏在单个页面中工作

如何在Drupal 8的用户配置文件页面上添加自定义HTML?

Magento 2:在head标签之后添加自定义脚本

如何在Jsoup解析中避免围绕html head标签

如何在自定义VuePress组件中使用vue-i18n?

如何用自定义 BBCode 标签替换 HTML 标签?

Vuepress 自定义主题和 postcss

使用 PHP 在 html 字符串中删除 AMP 页面的自定义标签

如何在PyYaml中添加自定义嵌套标签?

如何在 VuePress v.2.0.0 中添加组件?

如何在VuePress中添加突出显示代码?

使用自定义 html 标签在页面上显示图像

如何删除html标签和head标签之间的iframe标签?

如何在Visual Studio Code中自定义HTML标签的颜色?

如何在Fulma / Fable中插入自定义HTML标签?

如何在eex中向功能链接(Phoenix.HTML.link)添加自定义HTML