Page History
...
- Copy your logo to your theme's
assets/images/
folder. Anything in this theme folder will be deployed to/assets/[theme-name]/images/
URL path. Edit your theme's
app/header/header.component.ts
file. Swap the "templateUrl" property that your theme is using the local copy of "header.component.html"Code Block title header.component.ts @Component({ selector: 'ds-header', // styleUrls: ['header.component.scss'], styleUrls: ['../../../../app/header/header.component.scss'], // Uncomment the templateUrl which references the "header.component.html" file in your theme directory templateUrl: 'header.component.html', // Comment out the templateUrl which references the default "src/app/header/header.component.html" file. //templateUrl: '../../../../app/header/header.component.html', })
- Your theme's version of the
header.component.html
file will be empty by default. Copy over the default HTML code fromsrc/app/header/header.component.html
into your version of this file. Then, modify your copy of header.component.html to use your logo. In this example, we're assuming your theme name is "mytheme" and the logo file is named "my-logo.svg"
Code Block <header> <div class="container"> <div class="d-flex flex-row justify-content-between"> <a class="navbar-brand my-2" routerLink="/home"> <!-- Modify the logo on the next line --> <img src="/assets/mytheme/images/my-logo.svg" [attr.alt]="'menu.header.image.logo' | translate"/> </a> ... </header>
- Obviously, you can also make additional modifications to the HTML of the header in this file! You'll also see that the header references several other DSpace UI components (e.g.
<ds-search-navbar>
is the search icon in the header). You can easily comment out these tags to disable them, or move them around to change where that component appears in the header. - Any changes require rebuilding your UI. If you are running in "dev mode" (yarn start:dev), then the UI will restart automatically whenever changes are detected.
- NOTE: If you have a theme based on the "dspace" theme, be aware that theme places the header logo in two locations. This allows the "dspace" theme to support a single-line header (whereas the "custom" theme's header is multi-line):
- The Header component (as described above) is only used on user profile pages
- The Navbar component (
src/app/navbar/navbar.component.html
) is used everywhere else. The Navbar component can be customized in the same way as the Header Component. Just edit the logo path in the "navbar.component.html".
Customize Navigation Links in Header
This provides a basic example of adding in a hardcoded link to the header menu (displayed on every page in DSpace).
Edit your theme's existing
app/navbar/navbar.component.html
file. This file defines the entire <nav> which displays the navigation header across the entire DSpace site. While much of the content in this <nav> is loaded dynamically via other Angular components, it is possible to easily add a hardcoded link to the existing header. Find the section of this <nav> which is the <div id="collapsingNav">, as that's where you'll want to add your new link. See inline comments in the example below.Code Block title navbar.component.html <nav> ... <!-- This DIV is where the header links are added dynamically. You should see it surrounding all links in the header if you view HTML source --> <div id="collapsingNav" ... > <!-- The links themselves are in an unordered list (UL) --> <ul class="navbar-nav" ... > ... <!-- Add your new link at the end (or beginning) of this UL --> <!-- NOTE: All classes used below are the same Bootstrap CSS classes used by our 'dspace' and 'custom' themes. You can modify them if the link doesn't look correct in your theme. --> <li class="nav-item d-flex align-items-center"> <div class="text-md-center"> <a href="https://dspace.org" class="nav-link">DSpace.org</a> </div> </li> </ul> </div> </nav>
- Obviously, you can also make additional modifications to the HTML of the header in this file, as necessary for your navigation header. Keep in mind though that anything you remove may impact the dynamic content that is pulled into this navigation header.
- An example is that the header logo for the "dspace" theme also exists in this same file.
- Any changes require rebuilding your UI. If you are running in "dev mode" (yarn start:dev), then the UI will restart automatically whenever changes are detected.
Customize Footer
- First, you'll want to decide if you want to modify just the footer's HTML, or the footer's styles (CSS/Sass), or both.
- If you want to modify the HTML, you'll need to create a copy of "footer.component.html" in your theme, where you place your changes.
- If you want to modify the styles, you'll need to create a copy of "footer.component.scss" in your theme, where you place your changes.
Edit your theme's
app/footer/footer.component.ts
file. Swap the "templateUrl" and "styleUrls" properties, based on which you want to modify in your theme.Code Block title footer.component.ts @Component({ selector: 'ds-footer', // If you want to modify styles, then... // Uncomment the styleUrls which references the "footer.component.scss" file in your theme's directory // and comment out the one that references the default "src/app/footer/footer.component.scss" styleUrls: ['footer.component.scss'], //styleUrls: ['../../../../app/footer/footer.component.scss'], // If you want to modify HTML, then... // Uncomment the templateUrl which references the "footer.component.html" file in your theme's directory // and comment out the one that references the default "src/app/footer/footer.component.html" templateUrl: 'footer.component.html' //templateUrl: '../../../../app/footer/footer.component.html' })
- Now, based on what you want to modify, you will need to either update your theme's copy of
footer.component.html
orfooter.component.scss
or both.- To change footer HTML: Your theme's version of the
footer.component.html
file will be empty by default. Copy over the default HTML code fromsrc/app/footer/footer.component.html
into your version of this file. - To change footer Styles: Your theme's version of the
footer.component.scss
file will be empty by default. Copy over the default Sass code fromsrc/app/footer/footer.component.scss
into your version of this file.
- To change footer HTML: Your theme's version of the
- Modify the HTML or Sass as you see fit.
- If you want to add images, add them to your theme's
assets/images
folder. Then reference them at the/assets/[theme-name]/images/
URL path. - Keep in mind, all Bootstrap variables, utility classes & styles can be used in these files. Take advantage of Bootstrap when you can do so.
- If you want to add images, add them to your theme's
DSpace also has a option to display a two-level footer, which is becoming more common these days. By default. DSpace just displays a small, bottom footer. But, you can enable a top footer (above that default footer) by add this line into your theme's
footer.component.ts
Code Block title footer.component.ts export class FooterComponent extends BaseComponent { // This line will enable the top footer in your theme showTopFooter = true; }
This top footer appears in the
footer.component.html
within a div. Notice the "*ngIf='showTopFooter'
", which only shows that div when that variable is set to "true"Code Block title footer.component.html <footer class="text-lg-start"> <!-- This div and everything within it only displays if showTopFooter=true --> <div *ngIf="showTopFooter" class="top-footer"> ... </div> <!-- The bottom footer always displays --> <div class="bottom-footer ..."> ... </div> </footer>
- Any changes require rebuilding your UI. If you are running in "dev mode" (yarn start:dev), then the UI will restart automatically whenever changes are detected.
...